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:

Error
{
  "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

StatusWhat it means
200 OKIt worked.
204 No ContentIt worked, and there's nothing to send, such as a map tile with no areas in it.
206 Partial ContentYou asked for a byte Range of a file, as a PMTiles reader does, and got that part.
304 Not ModifiedYour cached copy is still current. See Caching.
400 Bad RequestA parameter is missing or malformed. detail says which.
404 Not FoundNothing matches what you asked for, such as an unknown measure or area code.
405 Method Not AllowedThe route takes a different method, such as a batch route that only takes POST.
409 ConflictWhat you asked for is ambiguous. The response lists the choices.
413 Content Too LargeA POST body is bigger than the route accepts. Send it in smaller batches.
414 URI Too LongThe request target is longer than the server accepts. Send fewer codes, or page the request.
415 Unsupported Media TypeA POST body isn't in a format the route reads. Send JSON, or CSV where the route accepts it.
416 Range Not SatisfiableThe byte range you asked for lies outside the file.
422 UnprocessableThe 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 RequestsYou've spent your requests for now. Retry-After says how many seconds to wait. See Rate limits.
451 Unavailable For Legal ReasonsThe API isn't licensed to serve it, such as a Northern Ireland postcode.
500 Server ErrorThe route failed unexpectedly. The response carries a requestId; quote it if you report the failure.
503 UnavailableThe 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:

CodeWhat happenedWhat to do
place_not_served422The 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_geography404That geography isn't available, or its areas aren't compiled.Check the spelling against List geographies.
unknown_release404The 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_release404The boundary release you named doesn't contain that area code.The response's presentIn lists the releases that do hold the code.
aggregation_not_supported422This 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_available422The 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_coverage422Some 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_place409The name matches several places that have different answers.Pick one of the choices in the response and pass its place reference.
incompatible_geometry422Not every area code in the data appears in the boundary release you chose.Find a release that fits with Build evidence.
invalid_format400This endpoint doesn't offer the format you asked for.Use one of the formats listed for the endpoint's format parameter.
invalid_cursor400The 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_parameter400This operation doesn't declare the query parameter you sent.Remove the parameter or replace it with the response's optional suggestion.
no_release_for_date404No boundary release covers that date (or that country).The absence field says why. Try a later date or drop country.
ambiguous_release409Several 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.