What is API Monitoring? Learn How to Monitor Your API Calls

Vittorio Rivabella
9 min readOct 19, 2021

--

Cover image of what is API Monitoring and how to monitor API Calls.

I was working in a startup when one of our APIs went down for 3hrs, losing money and customers. This is why I’ve created this guide where you will learn what is API Monitoring, why is important, and how to monitor your API calls using Treblle.

We will go through the main concepts of monitoring an API, what to monitor, and how to effectively set up an API Monitoring service able to give you the needed insights to make your API a reliable product.

What is API Monitoring?

API Monitoring is the practice of monitoring API (Application Programming Interfaces), usually in production environments, using third-party or proprietary services.

Setting up an API Monitoring service is key to gain visibility into APIs:

to stay informed about possible misbehaviors, and downtimes.

Having a way to monitor your APIs endpoints will allow you to constantly ping your APIs endpoints, returning information like:

There are also third-party services capable of expanding the features of API monitoring way beyond that, including documentations, smart analytics, and more, but we’ll see that later in this post.

Now let’s dig deeper into the reasons why API Monitoring services are key to build a successful product/tool.

Why is API Monitoring Important?

laptop on a desk with code

Whenever your API or one of its endpoints goes offline, or an error occurs while performing any action:
you want to be the first to be notified, informed, and able to repair the damage.

You want to act as fast as possible.

Think about a slow API, an API that doesn’t respect its documentation or worst one that is COMPLETELY down; those are all issues addressed by, you guessed that, monitoring your APIs aiming to:

All of these points contribute towards the creation of a service that ensures reliability for your customers and users. Let’s have a closer look at what they are, and why it is important.

API Availability — Minimize API Downtimes

It’s common to say that your API should stay 99% of the time online, to do so you need to have the right process in place to handle a potential crisis.

What if suddenly you can’t retrieve your users anymore or you fail some important business logic?
What if the entire backend goes down, and you’re not aware of that?

You need to make sure that your endpoints are readily available most of the time.

API Monitoring services will help you act as fast as possible using handy notification systems and clear error logs.

What if your API seems available but is not behaving as expected? This is called API Operability.

API Operability — Avoid inconvenient errors

I asked for a user and got back an Integer, the App crashed and lost thousands of dollars.

That’s something you want to avoid monitoring your API endpoints, making sure that are operating as expected.
What if the same error exposes some important information you can’t disclose?

A performant API Monitoring Tool will give you all the clues you need to debug your errors and find the guilty bug.

In other cases though, everything might work as expected, but your API calls are taking way too long to send a response, you want to monitor your API performances.

Monitor API Perfomances

You don’t want to wait 30 seconds to retrieve a user, not even 3.

Understanding the time your API requires to act is key to provide the best service and experience.
Track your API performance to optimize your code to consume the least amount of resources, and perform its logic in the shortest time.

Now that you know the main aspects to monitor in your APIs is time to understand How to monitor your API Calls.

How to Monitor API Calls to Create Better APIs

laptop on a desk with code to monitor API calls

You have two main ways to start monitoring your API Calls:

  • Building your own monitoring services.
  • Using Third-party services (suggested).

To be honest with you, if you are a huge company with millions in revenue, have very precise requirements on what to monitor, and can afford your proprietary API monitoring service, with the related dev team to maintain it: make your own API Monitoring tool, and I’m honored you are reading my article.

In the other 99% of cases, you want to use an API Monitoring service capable of providing you the right functionalities, in the fastest, cheapest, and most reliable way possible.

In both cases, you’ll need to choose a solution that allows you to:

  • Periodically check if all the endpoints are working,
  • Check if there’s an error occurring in your requests and what kind of error.
  • Get time of response.

The more the information, the better.

Now you’re wondering, what is an API Monitoring service? Which one should I choose?

Let me guide you through that.

What is an API Monitoring Service?

It’s a tool, a library, or an SDK that you’ll have to install in your backend code or connect to your API endpoints. The API Monitoring service will then start pinging your endpoints to retrieve specific information about:

Other solutions will have different capabilities such as Automatic Documentations, API Testing, Fully-fledged analytics, and notification systems.

There are a lot of different tools out there, and choosing the right one is a matter of trial and error, as well as necessities, let’s see how to choose the one that suits your needs.

Dashboard with data to conceptualize api monitoring

Choose the best service to Monitor your API Calls

You should primarily choose your API Monitoring service based on your needs:

What do you need to Monitor? What kind of information are you looking for? What’s your budget?

Here’s a list of parameters to help you chose your service:

  • Reliability -> How precise and constant the service is?
  • Functionalities and Analytics -> What kind of analytics does it provide?
  • User Experience -> Ease of implementation.
  • Adaptability -> Which uses cases does it suit?
  • price/requests ratio -> How much does it cost?

As always there are a lot of tools ready to give you a good amount of features for a good price, but the issue might be residing in the implementation process, compatibilities, or scalability properties.

I’ve personally tested tens of services looking for the one that better suited my needs, eventually, finding it.

The easiest way to monitor your API Calls — Treblle

What is API monitoring with Treblle — an API monitoring service

I use Treblle to monitor my APIs, I’m also working with their team and can confirm: they’re amazing.

Treblle has all the features you need to monitor your APIs plus an awful lot of features that will simply make your API development and testing experience, seamless.

It comes with a fully-fledged API monitoring suite plus:

  • Free plan.
  • Powerful API Analytics.
  • Auto Docs.
  • Smart Problem Tracking.
  • 1 Click testing.
  • Quality Scoring.

Let’s take a closer look at the functionalities Treblle offers and how to quickly set it up.

Treblle — All you need to monitor your API Calls

Treblle constantly tracks your API performances, logging all your need to know, in real-time.

This allows you to find, and understand your APIs, optimize, and correct potential flaws. It will give you information about:

This allows you to find, and understand your APIs, optimize, and correct potential flaws. It will give you information about:

  • Users.
  • Device/App.
  • Load time.
  • Location of request.

And much more, while keeping the implementation process very easy.

The other thing I love about Treblle is its reliability:
If Treblle goes down, your app doesn’t.
If your API goes down, Treblle notifies you.

And it does all of it without affecting your API performances.

Let’s see how to implement Treblle into your API for Free.

How to install Treblle to monitor your API Calls

First of all, you’ll need to register on the Treblle website.

Once you’ll have registered, you’ll need to create a new project and implement the library based on your backend language:

  • PHP
  • Laravel
  • NodeJs
  • .NET
Project page of treblle — Monitor your API calls with treblle

Implement Treblle to monitor your API Calls

Once you’ll have created a new project, implementing Treblle will be super easy, just follow the detailed instructions you’ll be provided with.

To implement Treblle with Node, for example, you’ll need to install the library from npm or yarn running:

npm install treblle or yarn add treblle

Once Treblle will be installed, you’ll just need to copy the following lines of code into your app.js, replacing them with your API key and project ID (those are automatically provided into the code if copied from the Treblle website).

// LOAD MODULES 
const express = require("express");
const { useTreblle } = require("treblle");
// INITIALIZE EXPRESS const app = express(); app.use(express.json());
// ATTACH TREBLLE WITH YOUR API KEY AND PROJECT ID
useTreblle(app, { apiKey: 'YOU API KEY', projectId: 'YOUR PROJECT ID'});

Once you’ll have implemented the library into your backend code, you’ll be ready to test your API using Treblle.

How to set up treblle to monitor your api website page

Test Your API Calls With Treblle

Send an HTTP request to your desired API endpoint and see the magic happening. Treblle will start showing a list of the tracked endpoints, click on one of them to see its details and analytics.

Choose your API Endpoint to monitor with treblle website page

Once clicked, you’ll be able to see:

  • Request Data.
  • Response Code.
  • Load Time.
  • Device.
  • Location of Request.
Get API Monitoring data with trebble, website page

Treblle will also automatically compile the documentation of your API, saving you tens of hours of work.

The documentation will describe everything about your API endpoints, from the types of data, required, and the auth specs, to a complete description of the response data.

Of course, there’s no good API Monitoring service without a proper error checking system.

Automatically generate API Documentation with treblle page.

Monitor API Errors With Treblle

Treblle API Error monitoring page

Whenever one of your API Calls fails, Treblle will catch the error and return a detailed description of what happened.
This will allow you to act fast, and promptly solving the problems affecting your services.

Last but not least, Treblle will allow you to perform a complete API Audit, automatically, to highlight the major issue of your API.

Treblle Automatic API Audit Score System

Going into the Score tab, Treblle will evaluate your API performances, giving you a complete report based on 3 main points:

Calculated using the data coming from your endpoints and API usage.

Treblle API Automatic score website page

Conclusions

Monitoring your API is key to ensure your services are reliable, efficient, and to provide your users and business with the best experience possible.

Being able to be notified as soon as an error happens and act to solve it and restore the standard functioning of your products is key to avoid losing customers, money, reliability, and credibility. In a matter of minutes, you’ll be usually able to set up your API Monitoring services and start tracking the performances of your APIs.

As said, I’ve found Treblle to be my go-to choice when it comes to monitoring my API calls, as it offers a handy free plan to test your projects, is easily scalable, and is very easy to set up.

--

--

Vittorio Rivabella

Content Creator and Fullstack Developer, turned Writer to help freelancers win the game. Monetize your skills: vitto.cc