How to create an API mock and test it in 5 minutes
Today I came across a free mock service called AMock.io and wanted to give it a try. The usage of this service is pretty straightforward and it does not even require someone to be registered to use it.
The tech stack that I will be using for this demonstration is the following:
- AMock.io | http://amock.io/
- ChatGPT | https://openai.com/blog/chatgpt
- Postman | https://www.postman.com/downloads/
I wanted to return an html payload with 202 Accepted for a GET request so I asked ChatGPT to write me a template with the return text “Success”. I also mentioned that I want it to be seen like Matrix style.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Success</title>
<style>
body {
background-color: black;
color: green;
font-family: 'Courier New', monospace;
font-size: 3em;
text-align: center;
padding-top: 20%;
}
</style>
</head>
<body>
Success
</body>
</html>
Then I created a mock API service by using amock.io with the below configuration.
The generated url for the mock was “GET https://amock.io/api/mediumtrial”.
I headed to Postman Desktop App and created a basic http request. Since this API has no parameter or authorization requirement. Just pasting the URL with the correct Action “GET” should work.
After clicking send button, the response and the code can be observed easily.
The last but the most important part was visualization of the template to see if it is really like Matrix style or not. To do this, Postman has a tab called “Preview”. So I clicked it and observed.
The result was the following:
So, that’s how one can set up his/her own mock API and test it in 5 minutes. (excluding the installation time -_-)