Using the API
Errors
When something goes wrong, the API tells you what happened and why, in the same format every time. Many errors are deliberate: the API would rather refuse than hand you a number that looks right but isn't.
What an error looks like
Errors follow the Problem Details standard (RFC 9457) and are always sent as application/problem+json, whatever format you asked for:
{
"type": "https://api.ukdataatlas.com/problems/operation-not-supported",
"title": "Operation Not Supported",
"status": 422,
"detail": "This measure is a median and cannot be combined over areas.",
"code": "aggregation_not_supported"
}title and detail are written for people. code is stable, so branch on that in your code. Some errors add more, like the choices for an ambiguous place name.
Status codes
| Status | What it means |
|---|---|
200 OK | It worked. |
204 No Content | It worked, and there's nothing to send, such as a map tile with no areas in it. |
304 Not Modified | Your cached copy is still current. See Caching. |
400 Bad Request | A parameter is missing or malformed. detail says which. |
404 Not Found | Nothing matches what you asked for, such as an unknown measure or area code. |
409 Conflict | What you asked for is ambiguous. The response lists the choices. |
410 Gone | That Atlas release is no longer served. |
422 Unprocessable | The request is clear, but answering it would be misleading, so the API declines. |
414 URI Too Long | The request target is longer than the server accepts. Send fewer codes, or page the request. |
429 Too Many Requests | You've spent your requests for now. Retry-After says how many seconds to wait. See Rate limits. |
500 Server Error | The route failed unexpectedly. The response carries a requestId; quote it if you report the failure. |
503 Unavailable | The data isn't ready yet. Try again shortly. |
Error codes
These are the code values you can rely on, with what to do about each:
| Code | What happened | What to do |
|---|---|---|
unsupported_geography404 | That geography isn't available, or its areas aren't compiled. | Check the spelling against List geographies. |
unknown_release404 | The geography exists, but has no boundary release with that id. | The response's availableReleases lists the ones it has. A release id names its coverage and product as well as its date, such as 2024-12-uk-bgc; latest picks the newest. |
area_not_in_release404 | The boundary release you named doesn't contain that area code. | The response's presentIn lists the releases that do hold the code. |
aggregation_not_supported422 | This measure can't be combined that way, like adding up medians or ranks. | Check the measure's aggregation with Get a measure, and use individual observations instead. |
conversion_not_available422 | The crosswalk can't convert this data without dropping, splitting or guessing values. | Try another crosswalk from List crosswalks, or keep the data on its original areas. |
partial_coverage422 | Some areas a total needs are missing, so no total is given rather than a quietly incomplete one. | See where the measure is published with Check a measure's coverage, then choose a period or group of areas it fully covers. |
ambiguous_place409 | The name matches several places that have different answers. | Pick one of the choices in the response and pass its place reference. |
incompatible_geometry422 | Not every area code in the data appears in the boundary release you chose. | Find a release that fits with Check which boundaries fit. |
invalid_format400 | This endpoint doesn't offer the format you asked for. | Use one of the formats listed for the endpoint's format parameter. |
invalid_cursor400 | The cursor wasn't issued by the API, or belongs to a different query. | Start again from the first page, and only pass back the nextCursor you were given for the same query. |
unknown_query_parameter400 | This operation doesn't declare the query parameter you sent. | Remove the parameter or replace it with the response's optional suggestion. |
no_release_for_date404 | No boundary release covers that date (or that country). | The absence field says why. Try a later date or drop country. |
ambiguous_release409 | Several releases from the same month could fit, and they differ in more than coverage. | Pick one of the choices in the response and use its release id. |
Handling errors
Check the status, then branch on code for the cases you want to handle. Here, asking for a total of median house prices is refused:
const response = await fetch(
"https://api.ukdataatlas.com/v1/data/house-price-median/aggregate?period=2022&geography=ward&boundaryYear=2020&place=E92000001",
);
if (!response.ok) {
const problem = await response.json();
if (problem.code === "aggregation_not_supported") {
// Show each area's value instead of a total
}
throw new Error(`${problem.title}: ${problem.detail}`);
}A 422 isn't a bug in your code. It usually means there's a better question to ask, and detail points you towards it.