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.
Required authentication header. Use the same application id as for the TravelTime API.
Required authentication header.
GET /v1/boundariesGet 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.
| Parameter | Type | Default | What it does | Example |
|---|---|---|---|---|
q | text | — | Search by name, with the best match first. Requires country. | q=camden |
country | country id | — | The country to search in with q. On its own, it returns every boundary in the country. | country=gb |
at | lat,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 |
parent | boundary id | — | Returns the boundaries inside this boundary. | parent=gb-greater-london |
type | boundary 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
| Code | HTTP | When |
|---|---|---|
location_required | 400 | The request has none of at, parent or country and is not type=country on its own, or it has q without country. |
too_many_locations | 400 | The request has two of at, parent and country at once. |
invalid_parent | 400 | There 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_type | 400 | type is not a boundary type that the country has. allowed lists them. |
All the location and paging error codes also apply.
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"| Namename | Typetype | Parent nameparent.name | Parent typeparent.type |
|---|---|---|---|
| Camden Square | ward | Camden | borough |
| Camden Town | ward | Camden | borough |
| Camden | borough | Greater London | region |
All 3 shown
Response
{
"results": [
{
"id": "gb-camden-square",
"name": "Camden Square",
"type": "ward",
"parent": {
"id": "gb-camden",
"name": "Camden",
"type": "borough"
}
},
"… 2 more rows"
],
"next_cursor": null
}Every boundary that contains a point, largest first. For this point, they are United Kingdom, England, Greater London, Camden and King's Cross ward.
Request
curl -H "X-Application-Id: YOUR_APP_ID" -H "X-Api-Key: YOUR_APP_KEY" \
"https://data.traveltimeapp.com/v1/boundaries?at=51.5307,-0.1238"| Namename | Typetype | Parent nameparent.name | Parent typeparent.type |
|---|---|---|---|
| United Kingdom | country | — | — |
| England | nation | United Kingdom | country |
| Greater London | region | England | nation |
| Camden | borough | Greater London | region |
| King's Cross | ward | Camden | borough |
All 5 shown
Response
{
"results": [
{
"id": "gb",
"name": "United Kingdom",
"type": "country",
"parent": null
},
"… 4 more rows"
],
"next_cursor": null
}All 32 boroughs inside Greater London. parent lists the boundaries inside a boundary. Without type, it lists everything inside it, including wards.
Request
curl -H "X-Application-Id: YOUR_APP_ID" -H "X-Api-Key: YOUR_APP_KEY" \
"https://data.traveltimeapp.com/v1/boundaries?parent=gb-greater-london&type=borough"| Namename | Typetype | Parent nameparent.name | Parent typeparent.type |
|---|---|---|---|
| Barking and Dagenham | borough | Greater London | region |
| Barnet | borough | Greater London | region |
| Bexley | borough | Greater London | region |
| Brent | borough | Greater London | region |
| Bromley | borough | Greater London | region |
5 of 32 shown · the other 27 are in the response
Response
{
"results": [
{
"id": "gb-barking-and-dagenham",
"name": "Barking and Dagenham",
"type": "borough",
"parent": {
"id": "gb-greater-london",
"name": "Greater London",
"type": "region"
}
},
"… 31 more rows"
],
"next_cursor": null
}GET /v1/boundaries/{id}Get one boundary, with its official name, bounding box and official codes. /v1/boundaries/gb returns the country itself.
| Parameter | Type | Default | What it does | Example |
|---|---|---|---|---|
include | cells | — | Adds cells, the boundary's H3 cells at resolution. | include=cells |
resolution | 9 | 10 | 9 | The 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
| Code | HTTP | When |
|---|---|---|
not_found | 404 | There is no boundary with this id. |
invalid_include | 400 | include is anything other than cells. |
too_many_cells | 400 | include=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_resolution | 400 | resolution is anything other than 9 or 10. allowed is [9, 10]. |
resolution_unindexed | 400 | resolution=10 in a country whose boundaries do not have res-10 cells yet. Use 9 there. |
cells_unindexed | 503 | include=cells is sent, but this boundary's H3 cells are not indexed yet. |
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"| Idid | gb-camden |
|---|---|
| Namename | Camden |
| Typetype | borough |
| Parent idparent.id | gb-greater-london |
| Parent nameparent.name | Greater London |
| Parent typeparent.type | region |
| Official nameofficial_name | London Borough of Camden |
| Bbox eastbbox.east | -0.1052 |
| Bbox southbbox.south | 51.5129 |
| Bbox northbbox.north | 51.5728 |
| Bbox westbbox.west | -0.2143 |
| Codes osmcodes.osm | R51827 |
| Codes onscodes.ons | E09000007 |
| Cellscells | 233 H3 cells |
Response
{
"id": "gb-camden",
"name": "Camden",
"type": "borough",
"parent": {
"id": "gb-greater-london",
"name": "Greater London",
"type": "region"
},
"official_name": "London Borough of Camden",
"bbox": {
"east": -0.1052,
"south": 51.5129,
"north": 51.5728,
"west": -0.2143
},
"codes": {
"osm": "R51827",
"ons": "E09000007"
},
"cells": [
"89194ad324bffff",
"89194ad3253ffff",
"89194ad325bffff",
"89194ad32c3ffff",
"89194ad32cbffff",
"… 228 more"
]
}GET /v1/boundaries/cellsFor 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:
- Location:
cellsonly - Paging:
limitandcursor - Output:
format - Long requests: the same fields as a POST body
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
| Code | HTTP | When |
|---|---|---|
location_required | 400 | The request has no cells. bbox, near and at don't work on this endpoint. |
invalid_resolution | 400 | resolution is anything other than 9 or 10. allowed is [9, 10]. |
invalid_cell_resolution | 400 | cells holds H3 cells that are not at resolution. |
resolution_unindexed | 400 | resolution=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.
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
}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"7 H3 cells; click a cell to open its row.
| H3 cellcell | Boundariesboundaries | Map |
|---|---|---|
| 89195da4d03ffff | St Pancras & Somers Town, Camden, Greater London +2 | |
| 89195da4d07ffff | Bloomsbury, Camden, Greater London +2 | |
| 89195da4d0bffff | Regent's Park, Camden, Greater London +2 | |
| 89195da4d0fffff | Bloomsbury, Camden, Greater London +2 | |
| 89195da4d13ffff | St Pancras & Somers Town, Camden, Greater London +2 | |
| 89195da4d17ffff | Bloomsbury, Camden, Greater London +2 | |
| 89195da4d1bffff | St Pancras & Somers Town, Camden, Greater London +2 |
Response
{
"resolution": 9,
"results": [
{
"cell": "89195da4d03ffff",
"boundaries": [
{
"id": "gb-st-pancras-somers-town",
"name": "St Pancras & Somers Town",
"type": "ward"
},
"… 4 more rows"
]
},
"… 6 more rows"
],
"next_cursor": null
}