Logo

API Tester

Test REST API with your code

The API Tester is a feature nested within JDoodle’s IDE, allowing you to test REST APIs directly alongside your code. Use this to quickly validate API requests and responses without switching tools.

Supported HTTP methods

MethodDescription
GETUse the GET method to retrieve data from a specified resource. This is a read-only operation that does not alter the server’s state.
POSTThe POST method submits data to the server to create a new resource. This action changes the server, such as adding new data.
PUTUse the PUT method to update an existing resource with new data. This method typically replaces the entire resource with the data provided.
PATCHThe PATCH method applies partial modifications to a resource. Unlike PUT, PATCH allows you to update specific fields without modifying the entire resource.
DELETEUse the DELETE method to remove a specified resource from the server. This operation deletes data.
HEADThe HEAD method retrieves the headers from a resource without fetching the body content. This is useful for checking if a resource exists or obtaining metadata.

Setting up request components

When configuring your API request, you have several components to customize:

Params

Add query parameters to your URL to modify or filter the request. Query parameters are appended to the URL after a ? symbol, with each parameter separated by &… For example, to filter users by age and status, you might use https://api.example.com/users?age=30&status=active.

Authorization

Proper authentication is crucial when accessing protected resources. JDoodle’s API Tester supports the following authentication methods:

No Auth

Select “No Auth” if the API does not require authentication. You can send requests directly without providing additional credentials, which is common for public APIs or endpoints that allow anonymous access. You may also use No Auth for APIs that simply use a clientID and secret passed in the request body.

Basic Auth

Basic Authentication requires a username and password to access the API. This method sends the credentials encoded in Base64 over HTTPS, ensuring they are transmitted securely. When using Basic Auth, the Authorization header is included in the request, formatted as Authorization: Basic base64encoded(username:password). For example, if your username is user123 and your password is securepass, the concatenated string user123:securepass is encoded in Base64 and included in the header. This method is straightforward but less secure than other methods, so it is typically used in secure, controlled environments or over encrypted connections.

JWT Bearer

JSON Web Tokens (JWT) provide a secure and stateless authentication method. After successfully logging in or authenticating with the server, you receive a token representing your identity and permissions. This token is then included in subsequent requests to protected endpoints. To use JWT Bearer authentication in your requests, include the token in the Authorization header in Authorization: Bearer your_jwt_token. The server validates the token on each request, allowing access if the token is valid and has not expired. This method is widely used for its security and scalability, especially in distributed systems and microservices architectures.

Headers

Include additional header information to specify details about your request. Headers can indicate the content type (e.g., Content-Type: application/json), set custom values, or handle other metadata. For example, setting Accept: application/json informs the server that you expect a JSON response. You can add custom headers required by specific APIs in the headers section. Ensure that each header is correctly formatted according to the API’s documentation.

Body

For POST, PUT, and PATCH, input the data payload in the request body. The body contains the information you want to send to the server, typically in formats like JSON or XML. For instance, to create a new user, you might include a JSON body such as:

{
  "name": "John Doe",
  "email": "john@example.com",
  "password": "securepass"
}

Ensure that the Content-Type header matches the data format in your request body. If you’re sending JSON data, set Content-Type: application/json.

Creating a request

  • Input the endpoint URL you wish to test. To open multiple testing tabs, click the + button beside your current tab.
  • Choose from GET, POST, PUT, PATCH, DELETE, or HEAD.
  • Configure parameters, authorization, headers, and body as needed.
  • Press send , and the server’s response will be displayed for you to review.