Redirecting to http://loopback.io/doc/en/lb2/Use-API-Explorer.html ...
You're probably not the only one who'll use the API you just created. That means you'll need to document your API. Fortunately, LoopBack generates a developer portal / API Explorer for you.
Get the app (in the state following the last article) from GitHub and install all its dependencies:
Run API Explorer
Run the application:
Now go to http://localhost:3000/explorer. You'll see the StrongLoop API Explorer showing the two models this application has: Users and CoffeeShops:
In addition to the CoffeeShop model that you defined, by default Loopback generates the User model and its endpoints for every application.
About LoopBack built-in models
Actually, LoopBack creates several other built-in models for common use cases:
Exploring the CoffeeShop model
Right now, you're going to "drill down" on the CoffeeShop model. Click on CoffeeShops to show all its API endpoints:
Scan down the rows of the API endpoints: you can see that they cover all the normal create, read, update, and delete (CRUD) operations, and then some.
Click on the first row, POST /CoffeeShops Create a new instance of the model and persist it into the data source to expand that operation:
Follow the instructions in the diagram above.
Click in Model Schema to get a JSON "data template" that you can edit in the data field.
Add some text for the
name property. You don't have to put anything for the
id property, because LoopBack will automatically manage it to ensure there is always a unique ID for each model instance.
Then click the Try it out! button.
You'll see information on the REST request submitted and the application's response (for example):
The Response Body field will show the data that you just entered, returned as confirmation that it was added to the data source.
Now click on GET /CoffeeShops to expand that endpoint. Click Try it out! to retrieve the data you entered for the CoffeeShop model. You should see the record you created using the POST API.
You may have noticed the accessToken field and Set Access Token button at the top right of the API Explorer window. Use these to authenticate a user and "login" to an app so you can perform actions that require authentication. For more information, see Introduction to User model authentication.