How to reduce development time? Mock your APIs

Search for a command to run...

No comments yet. Be the first to comment.
The Technical Articles series covers topics like online safety, authentication, encryption, Docker, API mocking, and cloud infrastructure. It offers practical insights and tutorials to enhance security and development workflows in modern tech.
How to build a simple AI assistant based IoT After getting an Android Things kit at Google Developer Day India, I have been very excited at getting into IoT and building with Android Things. Here I am finally messing around with it. Hardware Some of...
Explore ways to stay safe on the internet and why online security is important.

This article enables you to understand what WebAuthn (Web Authentication) is and how it works

I recently attended a training session with the Auth0 Dev Rel team on a very cool new feature they have added called Auth0 Actions. In this article, I am going to explain what is Auth0 Actions, why to use them, and how to set one up. What are Auth0 A...

Opinions expressed are solely my own and do not express the views or opinions of my employer. Hey Hackers! I'm Rohit Mathew and I'm the Software Development Engineer at McAfee Enterprise. First of all, a huge thank you to the HackerNoon community and...

Intro to Envelope Encryption & Key Management Systems

Dependent on the backend developer to start coding? Always being pestered to finish development soon so the frontend developer can start their work? Well, you don't need to wait anymore.
Today, the general office development environment has moved to an open office setup with dependencies between teams, in which development time is of the utmost importance. Anything the team can do to reduce development time is considered a huge advantage towards the development of the product. Recently, I found that using the mock servers provided by Postman is very helpful in helping reduce development time for both frontend and backend developers. So I'll quickly take you into the steps to make a mock server on Postman.
Download the Postman app from the following link and set up the application.
Create an account on the site.
After installing the application and creating an account you should get a screen like this:
Postman Application
Don’t forget to login to your account on the application after installing it.
So, click the new button and you get the above screen. Click on mock server and you get the following screen:
Create a Mock Server Initial Screen. Image from Toolsqa
Here, you can create a new API to mock or you can mock an existing collection. If you want to know what collections are, check them out here. In the above image you can build your REST API request with its respective HTTP Method. You also get to set your path/endpoint, the response code and the response body for it. You get something like this on completing those steps:
Example Endpoints. Image from Toolsqa
Click on Next and you then have to name the mock server and set any environment variable if needed. These environmental variables are not important now, so set them to No Environment. So now you get something like this:
Naming the server. Image from Toolsqa
Click on Next and your Mock Server is setup. You get a mock URL which links to the mock server built by postman. They always end with mock.pstmn.io. You can get the resulting data of your API by hitting that mock URL with the endpoint you made before.
Created Server Details. Image from Toolsqa
As soon as you close the above page, you find that a new collection has been created with your respective APIs and an environment variable has also been created with the URL equal to the mock URL of your server.
New Collection created. Image from Toolsqa
New Environmental Variable Created. Image from Toolsqa
On opening the endpoint we created, you need to setup the environment variable as show in the below image. This then setups Postman to accept the URL from the environment variables and that URL has been mapped to the URL of our mock server.
Setting Up Request. Image from Toolsqa
Now when you click Send you get the below response which is what we had mocked earlier:
Result of the Request. Image from Toolsqa
Now, you can manipulate and get your response as a JSON ,set up multiple API endpoints to handle specific responses and errors etc. Do go through the additional material provided below to explore building more sophisticated and better mock servers.
Both frontend and backend developers are able to start work without any hassle.
Mock servers are built on an agreed API contract and hence there will only be minor changes in the future for both sets of developers.
Building mock APIs is fast and hence easy for both set of developers to implement.
Reduces development time of both developers as they are not reliant on the other developer to start work.
Note: In the Postman free account, you are allowed 1000 hit per month on all mock servers. To get more hits, you will need to get a paid account from Postman.
I really hope that you find this article useful. I invite you to participate in the discussion in the comments below, I’m always interested to know your thoughts and happy to answer any questions you might have in your mind.
Thanks for reading! :)
P.S Do feel free to connect with me on LinkedIn