APIs are the backbone of software products. Whether the APIs are customer facing or for internal use, making sure that your APIs are up and running is crucial. In this post, we will see how to get started with API monitoring with Checkly.

Getting started

First, sign up for a Checkly account and create a new API check. You can add the API parameters yourself or import a curl command. You can also import APIs from Swagger.

Create new check in Checkly
Create new check in Checkly

You can add the following data to the HTTP request -

  • Body: You can choose to send the request without a body or add the body by choosing one of the body data types like JSON and GraphQL.
  • Headers: You can add HTTP headers as key/value pairs to set data like cookie, auth tokens etc.
  • Query parameters: You can add query parameters as key/value pairs.
  • Authentication: Basic authentication details can be added as part of the HTTP request. For other authentication schemes like OAuth and Bearer tokens, you can set them using setup scripts (mentioned below).

One great feature of Checkly is that you can set environment variables in your account, which can then be accessed throughout the request using handlebars notation like {{my_variable}}.

Setup and Teardown scripts

Setup script in Checkly
Setup script in Checkly

Checkly allows you to create scripts which are executed before and after the API check is run. Setup scripts are run before the API check, and you can use these to modify request parameters and get authentication data.

Meanwhile, teardown scripts are executed after the API check, and you can use this to remove sensitive data from the response. You can use Javascript to write these scripts, and you also have access to popular libraries, which can help you add powerful functionality to your checks.

API check assertions

You should set response time limits to set the API status to success, degraded or fail. Using the time limits can alert you about APIs which may be facing performance issues which can lead to downstream failures.

Checkly - set assertions for API check
Checkly - set assertions for API check

You can also use assertions to check if the API response meets certain conditions for success. You can set assertions on HTTP status code, JSON body, headers and the text body.

Check frequency and locations

You can select the frequency for running the API check e.g. every 5 minutes. You can also select from a list of locations across the world from where to run the check. You can then get reporting data for each location in the API check reporting.

Alerts

You can set up alerts in Checkly to receive information whenever there is a problem with your APIs.

Alert channels in Checkly
Alert channels in Checkly

You can also integrate tools like Spike.sh to get alerts on phone call, SMS, Slack and MS Teams whenever Checkly detects any issues. To make sure that important alerts don’t go unnoticed, you can create escalation policies in Spike.sh which automatically alert another team member if the first one contacted is not responding.

Conclusion

To make sure that your software is reliable, you should add monitoring to all your APIs using a tool like Checkly and set up alerts to the right team members with Spike.sh. If you want to learn how to monitor other important components of your system, feel free to email us at [email protected].