Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. Discuss
  3. Question about APIs

Question about APIs

Scheduled Pinned Locked Moved Discuss
4 Posts 3 Posters 697 Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • scookeS Offline
      scookeS Offline
      scooke
      wrote on last edited by
      #1

      So I'm reading up on API's, partly in my quest to expand my knowledge. I have a few conceptual questions I hope someone can shed some light on for me.

      API - I've always come across this as though it is a "simple command" to run or call. But then there are lines of code that are the API, and they get "called". In most cases the example is then what looks like an url, such as https://my.example.com/api/v1/cloudron/status (from https://docs.cloudron.io/api.html#tag/Cloudron/paths/~1cloudron~1status/get).

      so...

      1. I need to be able to write the code of the API in order to use it, and;
      2. the code that makes up the API is then saved as a file somewhere from which it is called (or run or activated or executed).

      For 1) In many cases I should be able to replace whatever the examples are in an API with my own info for it to work, right?

      For 2) it seems like these commands, saved in files, need to be accessible, either in/by a web browser, or by a CLI (either called by options or by making sure they are in the $PATH), right?

      So, using the examples from https://docs.cloudron.io/api.html#tag/Cloudron/paths/~1cloudron~1status/get, does this mean I need to have these various APIs (saved in files) hosted on a local Apache instance or something, in order for me to be able to "call" them? But, how would that work since the API is https://my.example.com/api/v1/cloudron/status, and not localhost? ** Or would I actually run it from localhost/status, since (from the example) the file "status" is what contains the important info:

      {
      "version": "5.1.0",
      "apiServerOrigin": "https://api.cloudron.io",
      "webServerOrigin": "https://cloudron.io",
      "provider": "linode",
      "cloudronName": "My Space",
      "footer": "&copy; 2020  &nbsp;  [Cloudron](https://cloudron.io) &nbsp; &nbsp; &nbsp;  [Forum <i class=\"fa fa-comments\"></i>](https://forum.cloudron.io)",
      "adminFqdn": "my.example.com",
      "activated": true,
      "setup": {
      "active": false,
      "message": "Fetching SSL certificate ...",
      "errorMessage": null
      },
      "restore": {
      "active": false,
      "message": "Downloading backups ...",
      "errorMessage": null
      }
      }
      

      Or do I need to save all these API files in /opt, or /sbin or something like that?
      I've been trying to read online tutorials, but like I mentioned in a similar post, most of these tuts assume a level of familiarity or grasp of the concepts, when for a user like me, lots doesn't make sense and the questions I have don't seem to be asked!

      Thanks everyone and anyone!

      A life lived in fear is a life half-lived

      1 Reply Last reply
      0
      • nebulonN Offline
        nebulonN Offline
        nebulon
        Staff
        wrote on last edited by
        #2

        The API style in Cloudron you are referring to is commonly called REST API, although Cloudron does not strictly follow REST patterns. It can be used with a multitude of clients. Some are libraries to be used withing other programs and they exist for all programming languages by now I would guess. Some other clients are browsers or also commandline clients like CURL.

        I think it might help you a lot to read up about REST APIs which should clarify things for you.

        Just a simple example, without an access token (so using just public API), run the following on a terminal with curl installed:

        curl -v https://my.<your cloudron domain>/api/v1/cloudron/status
        
        P 1 Reply Last reply
        3
        • nebulonN nebulon

          The API style in Cloudron you are referring to is commonly called REST API, although Cloudron does not strictly follow REST patterns. It can be used with a multitude of clients. Some are libraries to be used withing other programs and they exist for all programming languages by now I would guess. Some other clients are browsers or also commandline clients like CURL.

          I think it might help you a lot to read up about REST APIs which should clarify things for you.

          Just a simple example, without an access token (so using just public API), run the following on a terminal with curl installed:

          curl -v https://my.<your cloudron domain>/api/v1/cloudron/status
          
          P Offline
          P Offline
          plusone-nick
          wrote on last edited by
          #3

          @nebulon @girish Sorry to hijack this thread but its close enough to my topic/use case lol

          I am attempting to use the Private API with an access token ( I was able to create one via the user GUI and via the Public API following the docs) But I am having trouble using the token on a GET API call...Will you please provide an example of how and where to use the token?

          Some background: I am using Wappler.io to create the API GET call.
          389a88ee-d75e-485f-8ea0-ea994b1158f5-image.png

          As mentioned I was able to create the POST action with a JSON payload using the advised syntax to generate an API token:

          {
          "username": "julia",
          "password": "supersecret"
          }

          But I am not sure how to apply the token on a GET call
          Current output:

          {
          "status": "Unauthorized",
          "message": "Token required"
          }

          Any insight and guidance is greatly appreciated! 🙏
          +1

          ✌💙+1

          P 1 Reply Last reply
          1
          • P plusone-nick

            @nebulon @girish Sorry to hijack this thread but its close enough to my topic/use case lol

            I am attempting to use the Private API with an access token ( I was able to create one via the user GUI and via the Public API following the docs) But I am having trouble using the token on a GET API call...Will you please provide an example of how and where to use the token?

            Some background: I am using Wappler.io to create the API GET call.
            389a88ee-d75e-485f-8ea0-ea994b1158f5-image.png

            As mentioned I was able to create the POST action with a JSON payload using the advised syntax to generate an API token:

            {
            "username": "julia",
            "password": "supersecret"
            }

            But I am not sure how to apply the token on a GET call
            Current output:

            {
            "status": "Unauthorized",
            "message": "Token required"
            }

            Any insight and guidance is greatly appreciated! 🙏
            +1

            P Offline
            P Offline
            plusone-nick
            wrote on last edited by
            #4

            @nebulon @girish NVM! i figured it out!! 😇
            Had to append the URL call with the (?access_token=) parameter & token
            Figured it out with SoapUI first then got it to work in Wappler 😁
            +1

            ✌💙+1

            1 Reply Last reply
            3
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Bookmarks
              • Search