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. A few, such as a busy server, carry no code, so branch on the status for those.
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. |
206 Partial Content | You asked for a byte Range of a file, as a PMTiles reader does, and got that part. |
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. |
405 Method Not Allowed | The route takes a different method, such as a batch route that only takes POST. |
409 Conflict | What you asked for is ambiguous. The response lists the choices. |
413 Content Too Large | A POST body is bigger than the route accepts. Send it in smaller batches. |
414 URI Too Long | The request target is longer than the server accepts. Send fewer codes, or page the request. |
415 Unsupported Media Type | A POST body isn't in a format the route reads. Send JSON, or CSV where the route accepts it. |
416 Range Not Satisfiable | The byte range you asked for lies outside the file. |
422 Unprocessable | The request is clear, but answering it would be misleading, so the API declines. A geometry collection too large to build in one request is refused with the title Geometry Budget Exceeded, and its links.downloads points to the release's bulk downloads. |
429 Too Many Requests | You've spent your requests for now. Retry-After says how many seconds to wait. See Rate limits. |
451 Unavailable For Legal Reasons | The API isn't licensed to serve it, such as a Northern Ireland postcode. |
500 Server Error | The route failed unexpectedly. The response carries a requestId; quote it if you report the failure. |
503 Unavailable | The server can't answer right now. With the title Server Busy and Retry-After: 1, it's handling as many requests as it can, so wait and send it again. See Rate limits. Otherwise the data or geometry behind the request can't be served yet. |
Error codes
These are the code values you can rely on, with what to do about each:
| Code | What happened | What to do |
|---|---|---|
place_not_served422 | The place matched, but this measure cannot answer any of its meanings. | Read each candidate's reason, then choose a measure or a place it covers. |
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 Build evidence, 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 Build evidence. |
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/value?period=2022&geography=ward&codeYear=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.