API error surfacing helps you monitor site performance and user experience over time. Identify the API errors impacting your site goals the most, find the root cause of the error, and solve.
Read more about APIs and API errors
What is an API?
Application Programming Interfaces (APIs) are software intermediaries that allow two applications to talk to each other. An API has a set of protocols, procedures, and tools that facilitate the interaction between, for example, a web browser and server.
Every time you check a weather application on your mobile device or desktop you are using an API.
The app connects to the internet and sends data to a server. The server then retrieves that data, interprets it, performs the necessary actions, and sends it back to your machine. Your weather app then interprets the data and presents the information.
What is an API error?
API errors happen when something goes wrong with an API request, like if there is a missing parameter or a typo, for example.
Some of these errors can impact user experience while others go undetected by users. Monitoring API errors helps to ensure a drop in your site's performance is not due to an issue with an unresponsive or errorful API request.
Example:
If a payment provider API is not responding due to a typo in the request—then a visitor will be unable to complete their purchase; or if an inventory API is not showing correct data because a parameter is missing, users might be able to purchase an unavailable product; and so on.
How API errors are collected
API calls collected
Error analysis with API error monitoring tracks two types of HTTP-based APIs, sent by the user-agent (browser) to Servers:
- XMLHttpRequest API: The most commonly used API, which can be used to exchange data between a user-agent (browser) and a server.
- Modern Fetch API: Similar to XMLHttpRequest APIs but with a more powerful and flexible feature set.
Errors collected per pageview
A maximum of 20 API errors are collected per pageview.
Analyzing API errors
1. Click on the 'Filter' drop-down to filter by API errors.
2. Use the Error Analysis tabs to drill into the impact of errors. For example, use the Page groups tab to analyze the errors associated with a group of pages in a mapping.
3. Click on the '>' button to open the error side panel to view key data about the specific error.
4. Click on 'See Replays' to play back the session.
Sharing API details
- Open the Error side panel.
- Click the 'Copy error detail' button to copy and share.
The following details are displayed for each individual error:
-
Request URL - The destination of the request (if for instance, the request could be to complete a payment from a third-party provider).
-
Status Code - The relevant error response status code (400-599 codes).
-
Method - The request method, the two most common HTTP methods are “GET” and “POST”. GET requests data and POST sends it.
Investigate the status code
By reading status codes, developers can quickly see what is happening with the application and quickly check for errors.
There are two main categories of errors:
-
Client errors --- status 400 to 4xx
- The error comes from the initial request sent by the browser/web-app, meaning it contains a mistake.
- These errors are more problematic, as the error comes from the code itself in most cases, and reloading the page or resending the request won't solve the problem.
-
Server errors --- status 500 to 5xx
-
The error is fired during the process of the request by the server, meaning the server has encountered an internal error and can't resolve the request.
- Most server-side errors are temporary, if the user-agent sends the same request later on, reloading the page, the request might succeed.
-
Most common status error codes and their meanings:
Common client-side errors
Code |
Message |
Significance |
400 |
Bad Request |
the server could not process an API request due to invalid syntax: A typo or mistake while building out the request, a required query parameter missing or invalid, a malformed JSON body with missing semicolon or comma... |
401 |
Unauthorized |
returned when the API request is missing authentication credentials or the credentials provided are invalid |
403 |
Forbidden |
returned is in case the user did not request an API access token with the correct access permissions. |
Not Found |
Resource not found. Meaning either:
|
|
408 |
Request Time-out |
the request sent to the website server took longer than the website's server was prepared to wait |
413 |
Request Entity Too Large |
occurs when a request made from a client is too large to be processed by the webserver |
429 |
Too Many Requests |
Lots of public APIs include some form of rate-limiting. That is a way to protect the API provider from having a user making too many API calls, which can take up too many resources and potentially cause API crashes. |
Common server-side errors
Code |
Message |
Significance |
500 |
Internal Server Error |
The server encountered an unexpected condition that prevented it from fulfilling the request |
502 |
Bad Gateway ou Proxy Error |
The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request. |
503 |
Service Unavailable |
The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. |