. . .

The Apidocs

In the last tutorial, we built our very own rest-endpoint. We explained two ways to execute this restendpoint: One via the dashboard, and another one by accessing the URL which adresses the resource. There is a third way: The Apidocs.

  1. Open your browser and go the URL: [baseUrl]/apidocs . You should arrive here:
    images/download/attachments/27724626/apidocsIntro_temp.png

  2. First things first, enter your username, password and api Key:

    images/download/attachments/27724626/apidocsCreds.png

    1. In case you can not find the api-key of your app, check out the Configuration as shown:

      images/download/attachments/27724626/apiKey.png
  3. Now, scroll through the Apidocs until you find the name of your module. Just like with the examples we've been working through all this time, this is the "TutorialModule". Click on it to open the list of all rest-methods this module offers. There you should be able to see the method you already created "canIAffordIt". There, you can enter all informations just as you would when accessing the method through the dashboard. Hit execute and see if it works!
    images/download/attachments/27724626/myRestApidocs_temp.png

    This should already give you a hint about what the apidocs are: This site offers you an overview over all the rest-endpoints offered by the ApiOmat, as well as an interface to use them. In reality, almost everything you can do via the dashbord can also be done by executing the corresponding rest method via the apidocs. This includes: Creating new apps, creating new modules, creating new classes and CRUDing instances, basically everything we have learned up until this point.

  4. Just to give you one more example on how to use the apidocs, let's use the apidocs to create a new instance. Remember this tutorial where you created your first class-instance (a grocery)? You will do the same thing, just through the apidocs. To do that, search for the "apps"-section and click on it.
    images/download/attachments/27724626/appsDocs_temp.png

    You see the colored labels on the left of every method? These indeacate if the corresponding rest-method is of type GET, POST, PUT or DELETE. This already gives you a hint about what a method is for - a GET will retrive some kind of ressource, a POST will create some kind of ressource and so on.

  5. You want to create a new class instance. Click on the method which says - you already guessed it - "Create a new class instance". Enter the information as indicated below:
    images/download/attachments/27724626/createANewClassInstance.png

    Depending on the method you want to execute, you have to provide the appropriate parameters. In this case, it is the appName, moduleName, dataModelName and a body. The information provided through the body can sometimes be a bit difficult to replicate. Most of the time there is a example provided (as indicated by the model Schema) that you can copy and paste. In this case, the body needs to provide the moduleName and the dataModelName encoded as json as shown in the picture.

  6. Hit Try it out! The response let's you know if everything worked as intented. A response code starting with "2" means that everything worked fine, anything else means that something went wrong. "Request-URL" is especially interseting: It shows you how you could have executed this method by adressing it via this URL.

    images/download/attachments/27724626/tryItOut_temp.png
  7. Go to the dashbord and check if the new instance of your grocery has been added in the "Data"-View. If you forgot how to do that, check out this tutorial.

Now you've gotten to know various ways to use REST-endpoints provided by the ApiOmat. Now you may ask yourself - wait, is there a way to use external webserver Rest-APIs? There is! Learn how in the next tutorial .