Table of Contents
- What is API Analytics?
- Why is API Analytics Important?
- What is RapidAPI for Teams?
What is API Analytics?
[Analytics] is used for the discovery, interpretation, and communication of meaningful patterns in data
Analyzing data can determine the relationship between different parts of data and whether patterns exist. However, there are different ways to analyze data based on the type and origin. Therefore, the analyst has to choose a certain analysis to perform. This is preferably one that fits the type of data they have collected.
The two main types of data are qualitative or quantitative.
- Generally speaking, qualitative data can be an observation that is good, bad, colorful, tall, strong, etc.
- Quantitative data are observed as numbers.
A qualitative analyst at an art show may describe the quality of a painting by observing it then writing down words. In contrast, a quantitative analyst may measure the dimensions of the paintings and record numbers.
API analytics are all the ways that we can record qualitative and quantitative data from our API requests to be used in a meaningful way.
If we wanted to know how long an API request took, we could measure the latency. Latency is the time interval between events. Computers can do things pretty quickly, so this is usually measured in milliseconds (ms.).
Why Collect Qualitative Analytics?
Despite the importance of quantitative data in API analytics qualitative data plays an important role. An example of qualitative data in API analyses is the HTTP method of the request.
Additionally, you can use qualitative data to help categorize quantitative data. For example, a user is complaining that a certain action on their app takes a long time. In your analysis, you notice that a POST request (a type of HTTP method) is sent when the user performs the action and that it has an abnormally high latency. In this simple example, the use of both qualitative and quantitative API analytics produced a meaningful discovery in the data.
Why is API Analytics Important?
The importance of API analytics is inferred from the simple example at the end of the previous section. If someone collects analytics, they could use the analytics to describe, diagnose, prescribe, or predict patterns in the data.
These analytics have the power to solve real-world business problems that have a monetary impact on the organization.
API Analytics Example
To give a concrete example, an organization or developer subscribes to an API and, depending on its pricing, is given a quota. The plan costs $100 per month and allows for 10,000 API requests a month, but any requests over that quota incur a cost of $0.10 per request.
This can be interpreted to mean that any requests over the quota cost ten times more than the requests under the quota.
If the team manager receives an invoice that has an overage cost of $88 at the end of the month, they are going to want to know;
- Who sent the 880 extra requests
- Why there were so many requests
- What they can do to solve this problem
RapidAPI allows API subscriptions and usage to be divided at the organization, team, application, or API level.
Consequently, determining who sent excess requests is a simple task. You can pinpoint the requests down to the application.
Next, using RapidAPI’s analytics, you can view;
- when the requests were sent
- what the endpoint was
- which HTTP method was used
- the parameters for each request
All of these analytics help you determine why the requests were sent.
Determining what can be done is not as straightforward. There may be a rogue HTTP request function that keeps retrying on failed requests despite incorrect parameters. Another possibility is that the application saw an unexpected increase in users, which means that the forecasted requests were insufficient.
One scenario is solved by fixing the bug in the code, another is solved by upgrading the subscription plan to handle the increase in use.
Either way, the importance of collecting API analytics is clear!
What is RapidAPI for Teams?
RapidAPI for Teams is a way for an organization to manage API usage across the previously mentioned segments; teams, applications, APIs, and requests.
In addition to monitoring API usage, RapidAPI for Teams allows for publishing and securing internal APIs. When publishing, the team can decide if they want to use RapidAPI’s integration with OpenAPI to publish API specifications.
RapidAPI for Teams tracks quota usage per API and lets users quickly pinpoint weak points in there application or API. Furthermore, it provides a clean way to view your application’s network activity.
How to Track API Analytics & Monitor API Usage
First, to track API analytics across APIs you need to sign up for RapidAPI for Teams. Visit RapidAPI and select Create Organization in the navigation bar, and don’t worry, it’s free to create an organization.
After creating your organization, visit the Organization Dashboard. Here, you can invite users, create new teams, etc. You can explore the side navigation or learn more about each tab in the complete dashboard tutorial.
Next, create an example team, in addition to the default team that was created for you. This is done on the Manage Teams tab. I have named my second team “Other”.
Subscribe to APIs
If you are new to RapidAPI, the API marketplace is where you can discover, subscribe, and test external APIs.
Notice there is a dropdown on the pricing page to select the account that is making the subscription.
Subscribe to the Mashvisor API on both team accounts within the organization.
Then, go back to the endpoints tab.
On the endpoints dashboard, you can select the team and application that you wish to test the endpoint from. Send 2-5 test requests from different endpoints on each of the two teams that you have using the Test Endpoint button to send the request. This will give us some data to view on the dashboard.
Feel free to subscribe to other APIs, sending more requests, if you want to add more data to view in the dashboard. However, be aware of quotas and pricing plans.
Explore API Analytics
Now that we have some data to explore, click on My Apps in the top navigation bar.
The initial dashboard view gives us an immediate look into an API segment. The default view takes a look at total API calls for all the applications of the selected team.
Next, select the default application, and in the dropdown, choose the Analytics tab. This will segment the API calls into the requests coming from this application.
Here, you can segment your application requests by adding or removing APIs from the interactive input element above the chart.
After selecting the application analytics, you have the option to filter by the endpoint, but you can only view endpoint analytics one API at a time.
Therefore, remove any other APIs from the interactive API element except for the Mashvisor API. Then, in the endpoint search box, select one of the available endpoints.
It’s also important to note that whenever you segment the dashboard by a team, application, API, or endpoint the total API calls, error rate, and latency automatically adjust.
Finally, at the bottom of the dashboard, there is a sortable table that provides organized details on each request.
You can export different table analytics, or the entire dataset, as a CSV file to perform your analysis with a different tool or store the data locally.
Manage API Usage
It can sometimes be difficult to know how much of your API quota has been used. A single developer may be able to keep an eye on their application’s usage, but that luxury changes with scale.
In the previous section, we discussed viewing API usage within a team and by the application. You can also view API usage across teams. This is useful when two teams are subscribed to the same API.
Navigate back to the Organization Dashboard, using the top navigation bar, and select the Subscriptions & Usage tab on the left menu.
Notice that your subscriptions to different APIs are listed here. If you have a paid subscription plan with the API you can select that row in the table to glimpse some analytics.
Once clicked, you can hover over different bars on the chart to view how many API calls each team has made to this API.
Remember, this is a good place to view usage by team and quotas across all of your APIs. However, you can also view API usage by application and endpoint on the My Apps page.
View API Parameters
Earlier, I pointed out a table at the bottom of the dashboard on the My Apps page. The table has sorting capabilities and allows a user to export API analytics in bulk. Additionally, the table holds details on each request. The details contain metadata about the request and query parameters submitted as part of the request.
Let’s say that I noticed a few errors in my API analytics for the Mashvisor API, and I wanted to explore the cause. I navigate to My Apps and shrink my analytics criteria so I am viewing the application and API that is producing the errors. Furthermore, I sorted the table to view only API requests that returned a status code in the 400s or 500s.
I now can click on the individual details of each failed request to view the parameters. Subsequently, I can view the request parameters and the response object.
Nothing seems out of the ordinary with the request parameters.
However, the response message informs me, “no connection found for given state mu”. After a bit of research, I discover that the endpoint needs to receive a valid U.S state abbreviation when searching for properties and “mu” is not a valid abbreviation for any state.
It quickly becomes apparent that this endpoint is not validating parameters and wasting the API quota!
The example is simple, but being able to quickly view individual request parameters, request headers, response object, and response headers will save you time in diagnosing API troubles.
Data is powerful when working with computers and networks. Tracking API analytics can help solve problems and save money by making API management easier. Having an overview of external and internal API usage increases the chance that you will notice bottlenecks and increase application efficiency.
What are some common types of analytics?
Does Google Analytics Have an API?
Google offers a series of analytics APIs that developers can access. View three of the reporting APIs by following this link.
What are some Google Analytics API Alternatives?
You can find some here at https://rapidapi.com/blog/top-analytics-apis/.