Boundaries
Copy link

Find the administrative areas that a place is in, from the country down to the smallest local area, and protected areas such as National Parks. These endpoints also give you the boundary ids that group_by uses to split totals on the places, demographics, neighbourhood and proximity /cells endpoints.

This page answers questions such as:

  • Which borough is this address in?
  • What are the boroughs of London?
  • What is the id for Camden?

Boundaries come from OpenStreetMap relations and, in the United Kingdom, ONS wards. codes.osm is the OpenStreetMap id, which every boundary except ONS wards has. codes.ons is the GSS code, where there is one. /v1/catalog/{country} lists the boundary types a country has, and updated_at, the date they were last loaded.

For a country with no boundaries loaded, the endpoints return empty lists and not_found. A country that was loaded before boundary ids existed returns slug_unindexed (503) until it is reloaded.

Request headers
Copy link

Required authentication header. Use the same application id as for the TravelTime API.

string

Required authentication header.

A list of boundaries
Copy link

GET /v1/boundaries

Get the boundaries that match a name, contain a point (largest first), sit inside another boundary, or are in a country. You can narrow any of these searches with type.

Parameters
Copy link

ParameterTypeDefaultWhat it doesExample
qtext—Search by name, with the best match first. Requires country.q=camden
countrycountry id—The country to search in with q. On its own, it returns every boundary in the country.country=gb
atlat,lng—Returns the boundaries of the H3 cell that contains this point, largest first. They run from country down to ward, each inside the one before, followed by National Parks and National Landscapes.at=51.5307,-0.1238
parentboundary id—Returns the boundaries inside this boundary.parent=gb-greater-london
typeboundary type—Only return boundaries of this type. GB has country, nation, region, county, borough, ward, national_park and national_landscape, and /v1/catalog/{country} lists the types for each country. On its own, type=country lists the countries.type=borough

The endpoint also takes the paging parameters limit and cursor.

Each result has an id (such as gb-camden), name, type and parent. parent is {id, name, type}, or null for a country.

Errors

CodeHTTPWhen
location_required400The request has none of at, parent or country and is not type=country on its own, or it has q without country.
too_many_locations400The request has two of at, parent and country at once.
invalid_parent400There is no boundary with that id, or it is a National Park or National Landscape, which has no boundaries inside it. Use at instead.
invalid_type400type is not a boundary type that the country has. allowed lists them.

All the location and paging error codes also apply.

Examples

Search by name to get boundary ids that you can use across the API. This returns the borough gb-camden and the two wards named after it. Add type=borough to keep only the borough.

Request

curl -H "X-Application-Id: YOUR_APP_ID" -H "X-Api-Key: YOUR_APP_KEY" \
  "https://data.traveltimeapp.com/v1/boundaries?q=camden&country=gb"
200 · 3 boundaries
NamenameTypetypeParent nameparent.nameParent typeparent.type
Camden SquarewardCamdenborough
Camden TownwardCamdenborough
CamdenboroughGreater Londonregion

All 3 shown

Every boundary that contains a point, largest first. For this point, they are United Kingdom, England, Greater London, Camden and King's Cross ward.

All 32 boroughs inside Greater London. parent lists the boundaries inside a boundary. Without type, it lists everything inside it, including wards.

One boundary
Copy link

GET /v1/boundaries/{id}

Get one boundary, with its official name, bounding box and official codes. /v1/boundaries/gb returns the country itself.

Parameters
Copy link

ParameterTypeDefaultWhat it doesExample
includecells—Adds cells, the boundary's H3 cells at resolution.include=cells
resolution9 | 109The size of the H3 cells in cells. At 10, the boundary gets the res-10 cells of its res-9 cells, except those that another boundary at the same level holds with its own res-10 cells. Cells held by a boundary inside it still count. This is the same rule as on /v1/boundaries/cells.resolution=10

The response has the same fields as a list result, plus official_name, bbox as {south, west, north, east} in degrees, and codes.osm and codes.ons where they apply. With include=cells, it also has cells.

Errors

CodeHTTPWhen
not_found404There is no boundary with this id.
invalid_include400include is anything other than cells.
too_many_cells400include=cells is sent for a boundary of more than 100,000 H3 cells at resolution, such as a country. allowed_max gives the maximum.
invalid_resolution400resolution is anything other than 9 or 10. allowed is [9, 10].
resolution_unindexed400resolution=10 in a country whose boundaries do not have res-10 cells yet. Use 9 there.
cells_unindexed503include=cells is sent, but this boundary's H3 cells are not indexed yet.
Examples

Camden, by its id. include=cells adds the 233 resolution-9 H3 cells that make up the borough. You can send this list as cells to any /cells endpoint.

Request

curl -H "X-Application-Id: YOUR_APP_ID" -H "X-Api-Key: YOUR_APP_KEY" \
  "https://data.traveltimeapp.com/v1/boundaries/gb-camden?include=cells"
200 · one boundary
Ididgb-camden
NamenameCamden
Typetypeborough
Parent idparent.idgb-greater-london
Parent nameparent.nameGreater London
Parent typeparent.typeregion
Official nameofficial_nameLondon Borough of Camden
Bbox eastbbox.east-0.1052
Bbox southbbox.south51.5129
Bbox northbbox.north51.5728
Bbox westbbox.west-0.2143
Codes osmcodes.osmR51827
Codes onscodes.onsE09000007
Cellscells233 H3 cells

The boundaries each H3 cell is in
Copy link

GET /v1/boundaries/cells

For each H3 cell you send, get every boundary it is in, smallest first, followed by National Parks and National Landscapes. Cells come back in the order sent. A cell on a border takes its ward and that ward's borough.

This endpoint works at resolutions 9 and 10 and has no group_by. A res-10 cell takes the boundaries of its res-9 parent, except where a boundary has its own res-10 cells: then the cell takes the boundary that holds it at that level. For long lists, POST /v1/boundaries/cells takes the same fields as a JSON body (see Long requests).

The endpoint also takes the following common parameters:

Each result has a cell and boundaries, a list of {id, name, type} with the smallest first. The response also has resolution (9 or 10, as sent) at the top level.

Errors

CodeHTTPWhen
location_required400The request has no cells. bbox, near and at don't work on this endpoint.
invalid_resolution400resolution is anything other than 9 or 10. allowed is [9, 10].
invalid_cell_resolution400cells holds H3 cells that are not at resolution.
resolution_unindexed400resolution=10 in a country whose boundaries do not have res-10 cells yet. Use 9 there.

All the location and paging error codes also apply.

1. Send one cell, get one row
Copy link

Put the id of one H3 cell in cells. You get back one row for that cell. boundaries lists every boundary the cell is in, smallest first: its ward, borough, region, nation and country.

You send

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

You get

{
  "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"
        }
      ]
    }
  ],
  "next_cursor": null
}

2. Send several cells, get one row for each
Copy link

Separate the cell ids with commas. You get one row for each cell, in the order you sent them. These seven cells lie between Euston and St Pancras. They are all in Camden, in three wards. Select a cell to see its row.

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,89195da4d0bffff,89195da4d0fffff,89195da4d13ffff,89195da4d17ffff,89195da4d1bffff"
200 · 7 H3 cells

7 H3 cells; click a cell to open its row.

Try these requests in the playground →