RESTful API testing with Hoppscotch
Representational State Transfer (REST) APIs are a core part in communication between a web/mobile client and a server. The majority of web based application depend on REST APIs to fetch and modify data thus separating the data processing part from the front-end. Hoppscotch provides an fast and intuitive platform to develop and test REST APIs making it easier for developers worldwide to work efficiently.
REST usually uses the Hyper Text Transfer Protocol (HTTP) to setup communication between the client and the server. REST APIs ensure that the server transfers information in a standard format. A REST API call generally contains the following steps -
- The client sends a request to the server.
- The server authenticates the client and ensures that the client is authorized to request the information.
- The server accepts the requests and processes it.
- The server responds back with a code to tell the client if the request was successful or not and send the requested information if the request was successful.
Whenever a client requests an information, the sever always sends back a status code to indicate the status of the request. These are called HTTP status codes and are grouped into five types.
|Status Code||Response Type|
|4xx (400-499)||Client error|
|5xx (500-599)||Server error|
REST APIs also support HTTP methods to do operations on data. Hoppscotch supports the following methods out of the box.
|GET||Retrieve resource from a server|
|POST||Create or send new resource|
|PUT||Updating resource, can also be used for creating resource|
|PATCH||Similar to PUT, can be used to modify resource|
|DELETE||Delete resource from the server|
|HEAD||Read HTTP header information|
|CONNECT||To start a two-way communication with resource|
|OPTIONS||Requests permitted communication options for a given URL or server|
|TRACE||Used to debug the path to the target resource|
|CUSTOM||Create custom methods as per your need|
Using Hoppscotch to test your REST APIs
Hoppscotch provides you a minimal yet robust platform to test your REST APIs. The REST platform is the default platform you see when you open Hoppscotch.
You can enter the API endpoint and choose the HTTP method according to your needs from the dropdown menu. Once it is configured, click on the "Send" button and you will see the response returned by the server. It's that simple.
Now try it yourself, copy the below API endpoint and create a request.
Locally served APIs
If you are planning to use Hoppscotch to test your locally served APIs, it is reccomended that you install the Hoppscotch Browser Extension. Once installed, switch the interceptor on Hoppscotch to Browser Extension from the settings page or bottom bar to add support for localhost protocols.
Adding parameters to your request
You can also parameterize your URLs by specifying parameters in the URL itself or adding parameters manually in the parameters tab. To add a parameter in the URL, append
? at the end of the URL and add a parameter in
Working with environment variables
Environment variables allow you to store and reuse values in your requests and scripts.You can create a new environment by clicking the environments icon on the sidebar and clicking the
If you have more than one environments, select the environment whose variables you want to access. You can access the variables in the request section by referencing the variable in the following format
Hoppscotch has support for various types of authentication mechanism such as, Basic Auth, Bearer Token, OAuth 2.0 and API Key. You can configure this using the Authorization tab on the request section of Hoppscotch.
These are just few of the amazing set of features that Hoppscotch provides you to make your life easier as a developer. In addition to this, Hoppscotch supports features such as collections to save your requests, pre-requests to add dynamic behaviour to your requests and so much more.