Designing your API up front can be very useful where you have a significant amount of backend development to complete before there is sufficient functionality for front end development to easily commence.
Rather than waiting for the backend to be complete, the APIs can be agreed on up front. Tools like Azure API Management then allow you to mock up the APIs with sample data, allowing the front end development to commence much sooner.
The key benefit of using mocked APIs is being able to present the frontend to stakeholders for feedback really early.
First, watch the first 5 minutes of this video for a general introduction:
Watch Adam Cogan and William Liebenberg discuss the benefits:
To complete the following steps, you need to create an instance of Azure API Management in your subscription.
TIP: If you have Azure Credits, the Developer (NO SLA) edition is the cheapest option to test most of the features offered by API Management.
Figure: Create a blank API
Figure: Describe your API
Figure: Adding a new Operation
Figure: Add a response
application/json{ "data": "fake" }Figure: Add a representation for your response with fake data
Figure: Operation added successfully
Figure: Add the Mock Response policy
200 OK, application/json)Figure: Choose the response representation
Figure: Testing the mocked api operation
Figure: Response from the mocked operation
GET request to your REST Clienthttps://william-ssw.azure-api.net/dataOcp-Apim-Subscription-Key and value200 OK response and the mocked dataFigure: Calling our Data API from a REST Client
Mocking API responses is awesome! You are able to quickly add mocked responses for all your API endpoints without even having a real backend implementation, and your front-end application can make REAL API calls.