page-brochureware.php
Open API Designer

Test Your APIs Locally

At the lower left of the API Designer screen, click Start the Servers to run the app and the Micro Gateway locally.

Then API Designer will display a message like this:

API Designer Message

Depending on your project configuration and whether other processes are running, different port numbers may be displayed.

Click on the URL shown after “Application,” for example http://127.0.0.1:4001, to display the API root endpoint. You’ll see something like this in a new browser tab:

{"started":"2016-03-07T22:24:55.322Z","uptime":35.839}

This default message just shows when the app was started and how long it has been running.

Explore

Explore Your REST API

  • Click Explore Icon
  • The left pane shows all REST operations for the LoopBack models in the API. Models that are based on PersistedModel by default have a standard set of create, read, update, and delete operations.
  • Click POST /notes to display the endpoint to create a new model instance.
  • API Designer Explore

    The center pane displays summary information about the endpoint, including its parameters, model instance data, and response codes. The right pane provides template code to call the endpoint using curl command, and languages such as Ruby, Python, Java, and Node.

  • Copy the curl command, paste it into a console window, and add -k at the end of the command (as shown below) to avoid certificate errors. If you wish, edit the JSON data to make it more meaningful, for example:
  • curl --request POST \
      --url https://localhost:4002/api/notes \
      --header 'accept: application/json' \
      --header 'content-type: application/json' \
      --header 'x-ibm-client-id: default' \
      --header 'x-ibm-client-secret: SECRET' \
      --data '{"title":"Buy eggs and milk"}' -k
  • When you enter the command, the console will show the data entered, for example {"title":"Buy eggs and milk","id":1}.
  • Back in the API Designer, confirm that the operation added a model instance: In the left pane, click GET /notes to display the endpoint to find all model instances that match a filter (or all instances, if you don’t provide a filter).
  • Scroll the right pane down and then click the Call Operation button.
  • The first time you do this, you may see an error due to an untrusted certificate. When this occurs, click the link provided in the error message in the API Explorer to accept the certificate; then you can proceed to call the operations in API Explorer.

    Once you’re able to call the GET /notes API using the API Explorer, you’ll see something like this displayed below the button:

    [
      {
        "title": "Buy eggs and milk",
        "id": 1
      }
    ]