How to use the API client inside RapidAPI Studio?

Mon Aug 08 2022

8 min read

Having all the right tools during API development can help you write more secure APIs. These APIs are essential for building a functional product with separate codebases for client-side and server.

Over time, RapidAPI has provided several products to help developers build APIs. These products have allowed developers to not only test their personal or company APIs but also monetize them to earn a passive income.

Since API testing and debugging are essential, we will learn how to use API Client inside RapidAPI Studio today. But before we do it, let’s quickly look at RapidAPI Studio.

RapidAPI Studio

RapidAPI Studio houses different RapidAPI products into a single platform to provide an integrated user experience to build, consume, and govern APIs. It has the power of RapidAPI Provider to help you publish your APIs on RapidAPI Hub. It utilizes the strengths of Paw to create different branches, sessions, and environments to quickly debug your APIs.

If you want to learn more about RapidAPI Studio, I suggest you look at this guide.

API Client Inside RapidAPI Studio Features

RapidAPI Studio comes with an API client to help you debug your APIs quickly. It is web-based, so all you need is an internet browser and a working internet connection.

The API client inside Studio has many exciting features. Let’s look at some of them.

API Requests

The API client inside RapidAPI Studio allows you to create different request tabs. You can then use these tabs to test your API endpoints. Each tab has a similar interface that provides different options. You can set the request header, body, query parameter, and more. Afterward, you can click on the send button to test the endpoint.

Branches

RapidAPI Studio API client provides a branching feature that works almost the same way as the git branches. There is a main primary branch that you see and work with when starting to create API tests. At any point along the way, you can create another branch.

Since the new branch is created on top of the main branch, all the API tests inside the main branch will also be present in the newly created branch. Moreover, the new tests you create in the newly created branch will only be present here, not in the main branch.

The API client inside RapidAPI Studio lets the server store the cookies inside a Cookie Session. These cookies are automatically sent back during the subsequent requests to the same domain.

You can create multiple cookie sessions if you like. Each session can hold different cookies and can be used differently.

Environments

The API client inside the RapidAPI Studio allows you to create and manage production and staging environments for your APIs. You can set environment variables and use them as parameters during API testing.

There is no cap on how many environments you can create. Also, you can configure each environment differently than the last one.

Response Filtering

Sometimes we have to quickly search through an API response to check whether it contains what we need. If the response is huge, the whole ordeal can become difficult. Therefore, the developers at RapidAPI have added a response filtering feature inside the API client of RapidAPI Studio.

The filtering option asks the user to provide a JSON path expression. Once provided, the API client searches through the response, and if there exists a value that matches the expression, it shows it to the user.

Generate API Request Snippets

Inside the API client of RapidAPI Studio, you have the option to generate code snippets to call your testing API endpoint. You can then copy these code snippets and integrate them into your application. Currently, the API client of RapidAPI Studio supports 28 different languages, including JavaScript, PHP, Python, etc.

Breaking Down The User Interface

Let’s break down the user interface (UI) to understand what we get with this API client.

Branches UI

This is where you can handle your branches. You can create one by clicking on the plus (+) icon and giving your branch a name. You can also switch between branches from this area.

Sessions UI

Right below the branches, you will find a user interface to handle cookie sessions. By default, it will be set to the Default Session. You can create more sessions if you like.

Environments UI

This section of the UI helps you manage your environment. You can click on the plus (+) icon to add a new environment or the icon beside it to edit configurations of an existing environment.

Requests UI

You can create multiple requests inside the API client of RapidAPI Studio. All these requests can be managed from here. You can create a request, switch among multiple requests, or delete an existing one right from here.

Requests Tab UI

When you create a new request or click on any existing one, it opens a request tab. This tab is divided into two parts.

The first part is responsible for requesting the API. It contains everything from providing user options to adding query parameters to letting them set different authorization modes.

The second portion is about handling the response we have received from the API. You can look at the request header, response header, and response in different formats, etc.

Testing APIs Inside API client of RapidAPI Studio

I have already developed a Number API with two endpoints, and now I will use the API client inside RapidAPI Studio to test it and check if it works as expected. You can find the base URL of the API here.

→ STEP #1

Head over to RapidAPI Studio and sign up if you haven’t already. Once you are signed in, click on the Add API Project button. It will open a popup. Fill in on all the fields and press Enter.

Once the project is created, you will be redirected to another page.

→ STEP #2

Now click on Requests on the left sidebar if it is not selected. It will open up the API client inside RapidAPI Studio.

Let’s create a new environment. To do it, click on the plus (+) icon in the Environment section. It will open a popup where you can rename the environment and add variables. Let’s name our environment Testing, add a variable called number, and set its value to 213.

→ STEP #3

Let’s create a new request to test our base URL. We will make a GET request to the API and see what the API brings.

We did not get a 400 or 404 code. Instead, we received the 200 status code. It means the API is working as expected.

→ STEP #4

Now we will test the /number endpoint and see what it brings. For this, we need to create another API request using the plus (+) icon. We will make a GET request to the /number endpoint.

Lastly, we will click on the Send button once we have set the API endpoint.

As you can see, we have successfully received an array of numbers with a 200 status code.

→ STEP #5

We still have one more endpoint to test. The /even endpoint will receive a query parameter, i.e., number, and provide us with a response of whether the number was even or not. We will make a POST request to the API endpoint.

Earlier, we created a Testing environment and added an environment variable, i.e., number. We will use this variable now. To do that, first, create another API request using the plus (+) icon, add the API endpoint, change the HTTP method to POST, and select the Query option to add query parameters.

Now write number as a query parameter, and type { for its value. It will open a list. Select Environment Variable from the dropdown list. Once it is added, click on it. It will open a preview where all the environment variables for our current environment will be present. Select the number variable that we created earlier.

After this, click on the Send button.

I set the value of the environment variable to 213 and then used it as a query parameter value. Since it is an odd number, we received a false response.

Wrap Up

That’s all for today, people! This is just one tool in a bucket of tools that RapidAPI Studio provides. RapidAPI Studio is a complete toolkit that anyone can have during API development.

If you are interested in learning more about the RapidAPI Studio, I recommend you look at this piece we have written about it.

We also released a VS Code extension to test APIs inside VS Code. It’s called RapidAPI Client, and you can learn more about it here.