Requests and errors
Copy link

This page explains the parameters and behaviour that the endpoints from Places to Custom scores have in common, and lists their limits and error codes.

Location
Copy link

Every list and /cells endpoint takes exactly one of the following location parameters. Sending two at once returns a 400 too_many_locations error. The id filters (serves, parent, road, operator) specify a location of their own, so they don't need any of these.

There is no location parameter for "inside a borough". To search an area like that, send it as cells, a box or a radius.

ParameterTypeWhat it doesExample
nearlat,lngThe centre of a circle. Requires radius_m. Places, stations, open spaces and road entries and exits are returned nearest first, each with its distance_m.near=51.5307,-0.1238
radius_mmetresThe radius of the circle around near (max 50,000).radius_m=300
bboxsouth,west,north,eastA rectangle, in the same form as a map viewport. Latitude comes first.bbox=51.522,-0.140,51.538,-0.110
cellsH3 ids, comma-separatedA list of H3 cells (max 100,000), at resolution 9 unless resolution is set. This is typically a catchment from the TravelTime API. On /cells endpoints with group_by=cell and no sieve (within, beyond, min_population), every cell you send is returned, in the order you sent them. Where there is no data, a cell has 0, or null and a missing reason. If the list is too long for a URL, POST the same fields as JSON. With group_by=all at resolution 9, cells can also be compacted (the output of h3.compact_cells, at any resolution up to 9), up to 200,000 res-9 cells. Each id counts as the cells inside it, and the total counts each cell once.cells=89195da4d03ffff,89195da4d07ffff
countrycountry idThe whole country. This is only accepted for searches that return a small result: a q name search, a country's boundaries on /boundaries, within and beyond on /proximity/cells, POST /custom-scores/cells and /categories.country=gb
atlat,lngThe H3 cell that contains this point. On /places, this returns the places in that cell, and on /cells endpoints, the row for that cell. On /boundaries, it returns every boundary that contains the point.at=51.5307,-0.1238

Paging
Copy link

Every list returns {results, next_cursor}. To get the next page, pass next_cursor back as cursor. A next_cursor of null means you have every result.

For example, this request asks for three H3 cells, two per page:

Request

curl -H "X-Application-Id: YOUR_APP_ID" -H "X-Api-Key: YOUR_APP_KEY" \
  "https://data.traveltimeapp.com/v1/boundaries/cells?cells=89195da4d03ffff,89195da4d07ffff,89195da4d8fffff&limit=2"

Response

{
  "resolution": 9,
  "results": [
    {
      "cell": "89195da4d03ffff",
      "boundaries": [
        { "id": "gb-st-pancras-somers-town", "name": "St Pancras & Somers Town", "type": "ward" },
        { "id": "gb-camden", "name": "Camden", "type": "borough" },
        { "id": "gb-greater-london", "name": "Greater London", "type": "region" },
        { "id": "gb-england", "name": "England", "type": "nation" },
        { "id": "gb", "name": "United Kingdom", "type": "country" }
      ]
    },
    "… 1 more on this page"
  ],
  "next_cursor": "eyJxIjoiNDlkNTUzN2QwODAyZDIzNzg1ZTJlMzRmIiwiayI6WzJdLCJmIjoiODk1ZmNhNTAwZDk3ZjNlNjA1MGYzN2M5NzgyNzVhZWUifQ.P4UU8l7JVc4LnrGaMmUt4A"
}

Sending the same request with that cursor returns the third cell and "next_cursor": null.

Request

curl -H "X-Application-Id: YOUR_APP_ID" -H "X-Api-Key: YOUR_APP_KEY" \
  "https://data.traveltimeapp.com/v1/boundaries/cells?cells=89195da4d03ffff,89195da4d07ffff,89195da4d8fffff&limit=2&cursor=$NEXT_CURSOR"
ParameterType · defaultWhat it doesExample
limitinteger · 100The number of rows per page (max 10,000, or 100 with include=bands, open_spaces, cells or stops). Asking for more returns a 400 error rather than a shorter page. limit sets the page size, not the total number of results, so to get the 5 nearest, use limit=5 and ignore next_cursor.limit=500
cursoropaque string · —The next_cursor from the previous page. Send it with the same other parameters (or the same POST body). A cursor is tied to one data build. After a data update it returns a 410 cursor_expired error, so a set of pages never mixes data from two builds.cursor=Q2sxN2hKdnVQ.x9Lw

The one exception is an area search on POST /v1/custom-scores/cells, which has a result window of 10,000 H3 cells. When more cells pass, its pages hold the top 10,000 by points (ties are broken by h3). The top-level matched field counts every cell that passes, returned is at most 10,000, and next_cursor is null once the window is used up.

Per-cell endpoints
Copy link

Per-cell endpoints return one row per H3 cell by default. They can also return totals over the cells you sent, either per boundary or for all of them.

Each row includes its cell, and a per-cell response gives its resolution at the top level (except on /custom-scores/cells). A totals row includes the boundary {id, name, type} it sums instead, and a cell_count. Totals responses include a rollup block that says how each field was added up. It names every field or block individually (there are no wildcards), with one of the rules listed under Totals.

ParameterType · defaultWhat it doesExample
group_bycell | boundary type | all · cellcell: one row per H3 cell (max 100,000). A boundary type, such as borough or ward: your cells split by the boundary they fall in, with one row per boundary. Boundary types are listed on /catalog/{country} (National Parks and National Landscapes cannot be used), and work on places, demographics, neighbourhood, proximity and transit stations at resolution 9. all: one row for everything you sent, up to 200,000 res-9 cells sent as cells (or 100,000 for a box or circle).group_by=borough
resolution6–10 · 9The H3 cell size. Resolution 9 is about 0.1 km², and each step down is 7× bigger. /places/cells and the transit /cells endpoints accept 6–10, and /boundaries/cells and /open-spaces/cells accept 9 and 10. The other /cells endpoints are always resolution 9 and don't take resolution. With any group_by, this is the resolution of the cells you send. With group_by=all at resolution 9, cells can also be at resolutions 0–8.resolution=8

Output
Copy link

The format parameter sets the shape of the response. The data is the same in both formats.

ParameterType · defaultWhat it doesExample
formatjson | geojson · jsongeojson returns a FeatureCollection, with points for places and open spaces and H3 cell outlines for /cells rows. You can load it directly into Mapbox, Leaflet or QGIS.format=geojson

A response that includes sourced fields lists its data sources once, in a top-level sources map. When a field has no value, the row's missing: [{field, reason}] list says why. This is the only way gaps are reported, so no field is left out without a reason.

Long requests
Copy link

Every endpoint that takes cells also accepts a POST request with the same fields in a JSON body, for long lists. This allows up to 100,000 H3 cells, or ids covering 200,000 res-9 cells for a group_by=all total. To page through a POST, send the same body with cursor added.

For example, Camden's 233 H3 cells are too many for a URL, so they have to be sent in a POST body. The request below sends two of them, and the second is outside the coverage of every source.

Request

curl -X POST -H "X-Application-Id: YOUR_APP_ID" -H "X-Api-Key: YOUR_APP_KEY" -H "Content-Type: application/json" \
  -d '{"cells": ["89194ad321bffff", "89195da4117ffff"]}' \
  "https://data.traveltimeapp.com/v1/neighbourhood/cells"

Response

{
  "resolution": 9,
  "results": [
    {
      "cell": "89194ad321bffff",
      "noise": { "max_lden_db": 80.3, "road_lden_db": 64.0 },
      "air_quality": { "no2_ugm3": 34.7, "pm25_ugm3": 11.0 },
      "flood": "…"
    },
    {
      "cell": "89195da4117ffff",
      "noise": null,
      "air_quality": null,
      "missing": [
        { "field": "noise", "reason": "outside_source_coverage" },
        { "field": "air_quality", "reason": "outside_source_coverage" },
        "… 4 more"
      ]
    }
  ],
  "next_cursor": null,
  "sources": { "noise": "defra_noise_2022_r4", "air_quality": "defra_pcm_2024" }
}

Totals
Copy link

Each kind of field is totalled by one rule, and the response's rollup block names the rule used for each field. For example, over a box around London split by borough, place counts are summed and proximity times are averaged by population.

Request

curl -H "X-Application-Id: YOUR_APP_ID" -H "X-Api-Key: YOUR_APP_KEY" \
  "https://data.traveltimeapp.com/v1/places/cells?bbox=51.28,-0.51,51.69,0.33&include=categories&group_by=borough"
curl -H "X-Application-Id: YOUR_APP_ID" -H "X-Api-Key: YOUR_APP_KEY" \
  "https://data.traveltimeapp.com/v1/proximity/cells?bbox=51.28,-0.51,51.69,0.33&group_by=borough"

Response

{
  "resolution": 9,
  "results": [
    {
      "boundary": {
        "id": "gb-barking-and-dagenham",
        "name": "Barking and Dagenham",
        "type": "borough"
      },
      "cell_count": 259,
      "count": 1950,
      "category_counts": { "restaurant": 304, "bus_stop": 281, "hair_beauty": 141, "…": "…" }
    },
    "… 52 more"
  ],
  "next_cursor": null,
  "rollup": { "cell_count": "sum", "count": "sum", "category_counts": "sum" }
}
Kind of fieldRule
Counts, people, m²sum
Lines and open spaces (which span many cells)distinct
Shares and rateshousehold_weighted_mean or population_weighted_mean, depending on their base
Decibels (dB), times and ratingspopulation_weighted_mean (for times, over non-null H3 cells only)
Zonesmax
Shares of a total (covered_share)ratio_of_sums
Land cover sharesarea_weighted_mean
Deprivation decilesper_nation_population_share (never averaged)
open_spaces listsnone

Limits
Copy link

The limits are listed in the table below, with what happens when a request goes over each one.

LimitValueWhen exceeded
Rows per page, default100Pass next_cursor back to get the next page.
Rows per page, maximum (limit)10,000400 invalid_limit
Rows per page with include=bands, open_spaces, cells or stops100400 invalid_limit
Cells sent, or cells in a box or circle (except for the 200,000 limit below)100,000400 too_many_cells
H3 cells in a per-cell response (except /custom-scores/cells)100,000400 too_many_cells. Use group_by for totals, or send the list in parts
Res-9 H3 cells in a group_by=all total or on /custom-scores/cells200,000400 too_many_cells
Walk and drive times (within, beyond, covered_by)900 s400 invalid_within, invalid_beyond or invalid_covered_by, with allowed_max 900
radius_m50,000 m400 invalid_radius_m
resolution on /places/cells and transit /cells6–10, default 9400 invalid_resolution with allowed
Homes on POST /v1/custom-scores1,000400 invalid_homes
Custom-score search window10,000 H3 cellsPages stop, and next_cursor is null
Requests per application, across all Data API endpoints120 requests/minute. Contact us for a higher limit429 Too Many Requests

Errors
Copy link

Errors from the endpoints on the pages from Places to Custom scores all have the same shape:

  • code: the error code, for your error handling to check
  • message: a description of the error, to display
  • param: the parameter that caused the error
  • allowed or allowed_max (optional): the accepted values, or the maximum
  • doc_url: a link to the error on this page

The HTTP status is 400 unless the table says otherwise. The aggregation_read_budget_exceeded error, returned when a /places/cells count is too slow, has details instead of param and doc_url.

401 and 429 errors are not in the table. Every endpoint returns 401 Unauthorized when the X-Application-Id or X-Api-Key header is missing or wrong. The body is {"detail": "missing X-Application-Id or X-Api-Key header"} or {"detail": "invalid X-Application-Id or X-Api-Key"}, not the error shape above. A request over the rate limit returns 429 Too Many Requests. In that case, back off and retry.

The two category endpoints return errors in an older shape, without param or doc_url. See Catalog and categories for these errors. Every endpoint that is not on the pages from Places to Custom scores also uses the older shape, and its error codes are not listed on this page.

For example, these are the errors for a resolution the dataset does not have, and for a box with south above north:

Request

curl -H "X-Application-Id: YOUR_APP_ID" -H "X-Api-Key: YOUR_APP_KEY" \
  "https://data.traveltimeapp.com/v1/places/cells?bbox=51.522,-0.140,51.538,-0.110&resolution=12"
curl -H "X-Application-Id: YOUR_APP_ID" -H "X-Api-Key: YOUR_APP_KEY" \
  "https://data.traveltimeapp.com/v1/places?bbox=51.538,-0.140,51.522,-0.110"

Response

{
  "error": {
    "code": "invalid_resolution",
    "message": "places supports resolutions 6 to 10; got 12",
    "param": "resolution",
    "allowed": [6, 7, 8, 9, 10],
    "doc_url": "/docs/errors#invalid_resolution"
  }
}

Response

{
  "error": {
    "code": "invalid_bbox",
    "message": "bbox must be south,west,north,east with south<=north and west<=east",
    "param": "bbox",
    "doc_url": "/docs/errors#invalid_bbox"
  }
}
CodeHTTPparamWhen
Location
location_required400country · cells · —No near, bbox, cells or at was sent (param is country where country would also be accepted, and there is no param on /boundaries). Also returned for q with no location and no country, q on /boundaries without country, and /boundaries/cells without cells (param is cells).
too_many_locations400the second location parameterTwo location parameters were sent at once.
invalid_radius_m400radius_mradius_m was sent with bbox, cells or at but no near, near was sent without radius_m, or radius_m is outside 1 to 50,000 (allowed_max 50000).
invalid_cell_id400cellsThe cells are not H3 ids.
invalid_cell_resolution400cellsThe cells are not at resolution (9 unless sent), or, with group_by=all, they are at a resolution finer than 9.
invalid_input400cellsThe cells list is empty.
invalid_cells400cellsThe geohash cells have a different precision from precision.
too_many_cells400the location parameter: cells, bbox, near, country, within, beyond or includeMore than 100,000 H3 cells (allowed_max 100000), or more than 200,000 res-9 cells sent as cells for a group_by=all total or /custom-scores/cells (allowed_max 200000). On /boundaries/{id}, include=cells on a boundary of more than 100,000 cells. On the geohash grid, a box or circle of more than 10,000 geohashes (no allowed_max). Use group_by for totals, or send the list in parts.
invalid_country400countryThere is no country with that id. GET /v1/boundaries?type=country lists the countries.
country_not_allowed400countrycountry was sent on a search that does not return a small result.
out_of_coverage400bbox · near · at · cells · homesThe location does not touch any country we cover. Check that it is not in lng,lat order.
mixed_countries400homesThe homes are in more than one country. Send each country's homes in a separate request.
Paging
invalid_limit400limitlimit must be 1 to 10,000 rows per page (allowed_max 10000), or 1 to 100 with include=bands, open_spaces, cells or stops (allowed_max 100).
invalid_cursor400cursorThe cursor was not issued by this API, or was sent with different parameters. Pass next_cursor back unchanged, with the same request.
cursor_expired410cursorThe data has been rebuilt since this cursor was issued. Start again without cursor.
Per-cell endpoints
invalid_resolution400resolutionThe dataset does not have this resolution (allowed lists the ones it has). Boundaries and open spaces support resolutions 9 and 10.
resolution_unindexed400resolutionresolution=10 on boundaries or open spaces in a country whose data does not have res-10 cells yet. allowed is [9]. Use 9 there until the country's next build.
invalid_group_by400group_byThe value is not cell, all or a boundary type the country has (allowed lists them).
invalid_format400formatThe value is not json or geojson, or geojson was sent with a group_by other than cell.
invalid_include400includeThe value is not one of this endpoint's includes. On /proximity/cells, also returned for include with a group_by other than cell.
covered_by_needs_group_by400covered_bycovered_by returns totals rows, so it needs group_by=all or a boundary type.
Filters
invalid_category400categoryUnknown category id. /categories returns the category tree.
grid_not_supported400gridgrid=geohash only works with bbox, near and cells, on /places and /places/cells.
invalid_precision400precisionGeohash precision must be 6 or 7.
invalid_geohash400cellsThe cells are not geohashes, with grid=geohash.
mixed_precision400cellsThe geohashes have more than one precision.
invalid_mode400modeNot a transit mode. allowed lists the modes.
invalid_serves400servesThe values are not station ids, the stations are in two countries, or there are more than 1,000 (allowed_max 1000).
invalid_parent400parentThere is no boundary with that id.
invalid_type400typeNot a boundary type the country has. On /roads/access, not entry or exit.
invalid_layer400layerNot one of noise, air_quality, flood, crime, deprivation, broadband.
invalid_class400classNot an open-space class. /catalog lists the classes.
unknown_check_field400profile.checks.<key>.fieldNot a custom-score field. The message suggests the nearest match.
too_many_results400road · bbox · nearA roads search found more than 10,000 entries and exits in the location. Narrow the search.
Ids
invalid_id400id · roadNot an id of this kind (pl_, st_, ln_, os_, rd_, ra_).
not_found404id · countryThere is no place, station, line, road, entry or exit, open space, boundary or country with this id.
not_available_in_country404—This dataset is not loaded for the country.
Service
cells_unindexed503includeThe boundary's H3 cells are not indexed yet. Retry after the next build.
field_unindexed503profile.checks.<key>.fieldThe field is on /catalog but not indexed for search yet.
aggregation_read_budget_exceeded400—A /places/cells count per H3 cell took longer than the read budget allows. Ask for fewer cells or a narrower category.
pt_read_budget_exceeded400—Counting a transit /cells response took longer than the read budget allows. Send fewer cells.
pt_read_incomplete503—A transit /cells count did not finish. Retry the request.

Any other malformed parameter returns an invalid_<param> code named after the parameter, such as invalid_near, invalid_bbox, invalid_at, invalid_beyond and invalid_covered_by. The last two, and invalid_within, include allowed_max 900 when a condition is malformed. A request-validation failure returns invalid_ plus the top-level field, with the dotted path as param (for example, invalid_profile with profile.checks.gym.field). Malformed JSON returns invalid_body. In each case, message explains the problem.

A 503 with any other code is caused by the data store, not the request, and has no param or doc_url. index_unavailable, opensearch_unavailable and opensearch_error clear when you retry. opensearch_read_timeout and opensearch_request_rejected keep happening until the request asks for less, so send fewer cells or narrow the filters. <field>_unindexed errors (such as slug_unindexed and breadcrumb_ids_unindexed) keep happening until the country's next build.