Servage Magazine

Information about YOUR hosting company – where we give you a clear picture of what we think and do!

Testing APIs with mock data

Wednesday, April 5th, 2017 by Servage

api-mockIt is common to see a front-end application that gets its data from a back-end API. If you are working on one and don’t have a working API yet, where could you get data to test your application? You could always hardcode some fake data into the application itself, but what if you could use a real API and real HTTP requests instead? Let’s look into some free API mocking services that allow you to do this.

JSONPlaceholder

jsonplaceholder.typicode.com is an API testing service with a set of commonly used data. You can fetch users, posts, todos and even photos and their thumbnails from the API. In some cases, all type of data your application will need can be found from JSONPlaceholder, which makes it a valuable tool if you don’t have your own API yet. The service supports all of the common HTTP methods, such as GET, POST and DELETE. If the predefined set of data is not suitable for your application, you can download the source code of the API and use your own data set with it.

The Swar Wars API

SWAPI, the Star Wars API, is not actually built specifically for API testing. However, it’s a great tool for that purpose because it’s open to everyone and easy to use. As the name suggests, SWAPI is an API for the Star Wars universe. You can use it to get information about the characters, vehicles, planets and more about the universe. While you may not be interested in Star Wars related data in your final application, you can use it as a temporary data source with GET requests. The API does not require registration or authentication, so you can simply go to swapi.co and start consuming the data.

Mockable

Mockable is a highly customizable API mocking service for both REST and SOAP APIs. It allows you to build your API responses from scratch. The customizable options include a response status code, response body and content type. You can even set your own custom headers and choose a URI for the request. Mockable also supports the most common HTTP methods. Mockable is a freemium service with both free and paid accounts. The free service allows you to save your API mocks for up to 3 months. Demo accounts, which retain data for 24 hours, are also available without registration.

Mocky

Mocky is yet another simple mocking tool. It is not as customizable as Mockable but it can be used for free without registration. Mocky allows you to set your own response status code, content type, headers and response body. The tool is available at www.mocky.io.

Testing APIs with mock data, 5.0 out of 5 based on 2 ratings
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

No comments yet (leave a comment)

You are welcome to initiate a conversation about this blog entry.

Leave a comment

You must be logged in to post a comment.