Skip to main content

Rest API Tool

A REST API is an application programming interface that confirms to the constraints of REST architectural style and allows for interaction with RESTful web services. An API is a set of definitions and protocols for building and integrating application software. It’s sometimes referred to as a contract between an information provider and an information user—establishing the content required from the consumer (the call) and the content required by the producer (the response).

In other words, if you want to interact with a computer or system to retrieve information or perform a function, an API helps you communicate what you want to that system so it can understand and fulfill the request. You can think of an API as a mediator between the users or clients and the resources or web services they want to get.

Add New API Request

In Sparrow, you can add an API request as defined in the collection section or by clicking the + icon beside the tab or beside the filter icon.

addnewAPIreq

A new API request would be created with the request type as GET request. You can rename the API request by using the right-click options against the API request created.

API Request Elements

A REST API can be of different types – GET, POST, PUT, DELETE, PATCH, and so on. You can select the type of request from the dropdown options provided.

Beside the type of the API request, a text box is provided to enter the endpoint of the API. Once you have selected the request type and provided the endpoint of the API, hit the send button to send the request and get the response.

You can change the type of view of the API request into Horizontal or Vertical view. You can change the view as per your convenience.

addnewAPIreq

Parameters

Parameters refer to the values that you include in your API requests to customize and modify the behavior of those requests. Parameters are crucial for interacting with APIs because they allow you to send specific information to the server, retrieve specific data, or execute certain actions.

There are different types of parameters, and their usage depends on the API you are working with. The most common parameter used in API requests are query parameters. These are key-value pairs appended to the end of the URL in a GET request. They are used to filter, sort, or modify the response data. For example, in the URL https://api.example.com/users?name=John&age=25, "name" and "age" are query parameters.

addnewAPIreq

  1. To provide the parameters, just enter the parameter key and the value. Once you enter the key of the first pair, a second row is created automatically for the second key-value pair entry if needed.

  2. The parameters entered are appended to the API requests automatically. Suppose if you have entered many parameters but do not want to send a few parameters as part of the API request, then you can uncheck the checkbox or delete the parameter by clicking the delete icon provided against each parameter.

  3. Use the Bulk Edit option to add or edit multiple parameters simultaneously by toggling the bulk edit button. After making the necessary changes, toggle the switch again, and all data will be presented in a key-value format. This feature streamlines the process of updating multiple entries efficiently.

Request Body

Request body refers to the data that you include with a request, typically in the form of payload, when making HTTP requests that require additional information beyond the URL, headers, and so on. The request body is commonly used in HTTP methods such as POST, PUT, and PATCH to send data to the server.

The content of the request body is determined by the type of data the server expects and the content type specified in the request headers. Common formats for request bodies include JSON, XML, form data, and others. The structure and content of the request body depend on the API endpoint you are interacting with.

The request body is a critical part of many API interactions, as it allows you to send and receive data in a structured format.

  1. For the request body, select the data types from the dropdown.
  2. Once you select the data type from the dropdown, provide the request body in the space provided.

addnewAPIreq

Headers

Request headers in Sparrow, as in any HTTP request, are key-value pairs included in the header section of the request. These headers provide additional information about the request or the client making the request. Headers play a crucial role in communication between the client (Sparrow) and the server. In Sparrow, you can easily set and manage these headers for each request.

  1. To provide the headers, just enter the header key and the value. Once you enter the key of the first pair, a second row is created automatically for the second key-value pair entry if needed.

  2. Suppose if you have entered many header key-value pairs, but do not want to send a few headers as part of the API request, then you can uncheck the checkbox or delete the headers by clicking the delete icon provided against each header.

  3. In addition to the above, you can also see the section dedicated to auto-generated headers. These are the headers generated automatically and would be passed automatically. However, you have the liberty to check or uncheck the auto-generated headers which are not mandatory.

  4. Use the Bulk Edit option to add or edit multiple headers simultaneously by toggling the bulk edit button. After making the necessary changes, toggle the switch again, and all data will be presented in a key-value format. This feature streamlines the process of updating multiple entries efficiently.

addnewAPIreq

Each request in your collection can have its own set of headers, allowing you to customize the information sent to the server with each request.

Authorization

Authorization refers to the process of providing credentials or tokens to authenticate and verify the identity of the client making an API request. Authorization is essential when interacting with secure APIs that require authentication to ensure that only authorized users or applications can access protected resources. Sparrow provides various methods for handling authorization, making it convenient for users to interact with authenticated APIs.

Here are some common methods of authorization in Sparrow:

  • Basic Auth: This method involves sending a username and password as part of the request headers. The credentials are typically encoded in Base64 format. In Sparrow, you can enable Basic Auth for a request by entering the username and password in the request settings.

addnewAPIreq

  • Bearer Token: Bearer token authorization involves including a token in the "Authorization" header of the request. This token is often obtained through a separate authentication process, such as OAuth 2.0. In Sparrow, you can set the type of authorization to "Bearer Token" and provide the token value.

addnewAPIreq

  • API Key: Some APIs require an API key for authentication. In Sparrow, you can include the API key in the request headers by specifying the key name and value. API keys are often provided by the API provider upon registration.

addnewAPIreq

Response Body

Response body refers to the data sent back by the server because of an API request. When you make an HTTP request using Sparrow, the server processes the request and sends a response, which typically includes information or data in the response body. The response body is crucial for understanding the outcome of the request and extracting the relevant data returned by the server.

To view the response body in Sparrow:

After making a request, the response body is displayed in the "Body" tab at the bottom of the request pane. You can switch between different views, such as "Pretty" for formatted JSON or "Raw" for the raw, unformatted response.

Understanding the response body is crucial for API testing and development, as it allows you to verify that the server has provided the expected data and helps troubleshoot any issues with the API request.

addnewAPIreq

Response Headers

In addition to the response body, the server sends headers containing metadata about the response. These headers may include information about the content type, encoding, and other details.

addnewAPIreq

Beautify, Copy & Download Response

Once the response is received from the server, the user can copy the response generated, with the help of the copy icon provided in the response section.

In addition to this, a user can download the response in any format, using the download icon.

The user can format the response using the Beautify button provided in the response section.

addnewAPIreq

Save Request

Suppose if you would want to save the API request, then you will have to click on the Save Request button provided in the API request screen.

  1. Once you click Save Request, a popup opens which would provide an avenue to the user to save the API request with the request name. Provide the request name in the text field provided.

addnewAPIreq

  1. You can see the description of the API as well which would be optional in nature. If you provided the description in the documentation section, then the same would be visible in this section.

  2. You can save the request into an existing collection which would be displayed on the screen by just clicking the collection OR you can create a new collection by clicking the + Collection button available at the bottom of the screen.

  3. Once you have selected/added a collection, you would be navigated to the next step wherein you can save the request under the collection, or you can select the folder/provide the name of the new folder as well to which the request needs to be saved. A new folder can be created with the help of the + Folder button.

addnewAPIreq

  1. Click the save button to save the request OR click Cancel to abort saving the API request.

  2. To view the best practices for naming the API request, click on the “?” icon provided in the popup window.

addnewAPIreq

Documentation

You can provide a detailed description for the API in the documentation section, ensuring that anyone accessing the API will easily understand its functionality. By clicking on the Generate Documentation button, our Sparrow AI will automatically create comprehensive API documentation for you, saving time and effort while ensuring accuracy and clarity.

addnewAPIreq