Let's build an API using the API Designer UI to manage stocks in a portfolio and deploy the API to the cloud so it is available for any user to test drive and give feedback.
After you log in, first create an API project by clicking on the "+" button beside the Choose Project select box,
enter the project name & description on form on the the right side and click the Add Project button. Note,
you could import Jumpstart script, OpenAPI or a Postman collection by choosing the import option.
Let's Build this API
The following API will support CRUD for portfolios and stocks in portfolios and we'll support GrapbQL as well:
/portfolios | |
/stocks | |
/portfolios/{id}/stocks |
First let's create a Portfolio resource for the path called "portfolios". This resource will describe the properties of a Portfolio, such as name and description.
We will create the Portfolio Resource using the Form builder. Add add each property and then click Create. We'll just add a name and description property for now. Look to the Resources on the left and you will see the Portolio Resource.
Next, lets create the Stock Resource using the copy/paste JSON feature. This is handy if you have the JSON for resource such as from a previous API version. Copy and paste a JSON example for a Stock Resource and click Create. Look to the Resources on the left and you will see the Stock Resource. And note our JSON had a nested object called exchange, you'll see on the left in the Data Types section called Exchange.
When a Resource is created, and for convenience, a default path is created for that resource based on the name. Click on API Paths on the left, you'll see the paths for /stocks and /portfolios that were auto-created when we created the resources.
We now will create a Path for portfolios/{portfolioId}/stocks. Click Create a Path and specify the Resource and select collection. Single resource is when only one instance of the Resource.
Click on API Paths, click on Deploy API to Cloud and for now just use the defaults and click create.
You'll see all the information for the Endpoint with the URL at the top of page. You can instantly send requests to your new Endpoint, a curl command is provided, or use PostMan/Insomnia, etc. to send CRUD requests to your Endpoint.
More prototype artifacts are provided as below.
Further down on the Endpoint screen, you will see the endpoint keys. You will give an access key to your external users to send API requests, such as the following using the full access key:
curl -H "x-endpoint-key:fff089056d6144fc9530c557937af63e" https://api.restpoint.io/api/portfolios
You can view your Endpoint API's using Swagger UI or ReDoc. Simply copy the URL to your browser, note the Endpoint key provided by default is full access.