Boundaries

Find boundaries contained by a place

Signed in? Open this endpoint in the dashboard playground, which uses your organization automatically. Signed out, use Try in Playground below with your API key.

GET
/boundaries/consists-of

Find child boundaries contained by the place identified by id. Use boundary to select the boundary type, sublevel to control the nested administrative depth, and geometry to choose representative points or simplified polygons.

Getting an id. Call /boundaries/part-of with a lat/lon and take the properties.place_id of the boundary you want, for example gp:osm:r161816 (Indiana) or gp:osm:r68841 (Ontario). Any place_id returned by this API that refers to an administrative boundary or a postal code boundary works. Place IDs have the form gp:<kind>:<key> (gp:osm:r161816, gp:pc:US-46201); treat them as opaque strings. Geoapify's own place ids are not understood.

How it works. For boundary=administrative the result is every administrative boundary (OpenStreetMap admin_level 2 to 11) whose representative point lies inside the parent and whose level is deeper than the parent's. Admin levels are sparse in OpenStreetMap, so sublevel=N returns the N-th distinct level present below the parent, not "parent level + N". For boundary=postal_code the result is the ZCTA5 (US) or FSA (Canada) polygons whose representative point lies inside the parent; only sublevel=1 has data. Results are ordered by name (administrative) or code (postal_code). Every feature carries a datasource: OpenStreetMap boundaries cite "© OpenStreetMap contributors" (ODbL); postal boundaries cite US Census TIGER/Line ZCTA5 or Statistics Canada FSA.

Deviation (empty): only administrative and postal_code have data. Every other boundary value is accepted and validated but returns an empty FeatureCollection with an X-Boundaries-Note response header ("consists-of has data for administrative and postal_code only"). A gp:addr, gp:tz or gp:iso id, or an id that matches nothing, also returns an empty FeatureCollection (not 404).

Deviation (extra): datasource.raw carries the source identifiers of the boundary (osm_id, osm_type, admin_level, and wikidata, wikipedia, ISO3166-2 when present) rather than the full OpenStreetMap tag set; most optional Geoapify properties (formatted, categories, website, name_international, wiki_and_media, timezone ...) are not filled. Postal features additionally carry postcode and postal_code.

Not supported: nothing is removed; every upstream parameter is accepted. Geoapify's legacy place ids are not understood, and unknown ids return an empty FeatureCollection rather than 404.

Example: GET /boundaries/consists-of?id=gp:osm:r161816&apiKey=YOUR_API_KEY returns the counties of Indiana.

Authorization

queryapiKey<token>

Your API key from the dashboard, sent as ?apiKey=<key>.

Query Parameters

id*string

Place ID of the parent boundary, as returned in properties.place_id by this API (recommended source: /boundaries/part-of). Formats: gp:osm:<n|w|r><osm id> for an OpenStreetMap boundary, gp:pc:<US-ZIP|CA-FSA> for a postal code boundary. gp:addr, gp:tz and gp:iso ids have no

Length3 <= length <= 2048
boundary?string

Boundary type to return. Only administrative and postal_code have data.

Deviation (empty): every other value is valid but returns an empty FeatureCollection.

Deviation (extra): protected_area, national_park, aboriginal_lands, census, school_district, forest, hazard and regional_park are our additions to Geoapify's enum (they return an empty result here, as consists-of data covers only the two types above).

Default"administrative"
Value in"administrative""postal_code""political""low_emission_zone""public_transport""traditional""timezone""religious_administration""religious""place""neighborhood""region""municipality""barony""town""health""historic""historic:administrative""protected_area""national_park""aboriginal_lands""census""school_district""forest""hazard""regional_park"
sublevel?integer

Nested boundary depth.

Deviation (approximated): counts the distinct admin_level values present below the parent (levels are sparse in OpenStreetMap), not parent level plus N. For postal_code, only 1 returns data.

Range1 <= value <= 20
Default1
geometry?string

Geometry representation for returned boundaries. point returns representative points and is the default. The geometry_* values return simplified Polygon or MultiPolygon geometry at the specified accuracy in meters.

Default"point"
Value in"point""geometry_1000""geometry_5000""geometry_10000"
lang?string

Language used for boundary names and address fields (falls back to the default OpenStreetMap name when a boundary has no name in that language).

Default"en"
Value in"ab""aa""af""ak""sq""am""ar""an""hy""as""av""ae""ay""az""bm""ba""eu""be""bn""bh""bi""bs""br""bg""my""ca""ch""ce""ny""zh""cv""kw""co""cr""hr""cs""da""dv""nl""en""eo""et""ee""fo""fj""fi""fr""ff""gl""ka""de""el""gn""gu""ht""ha""he""hz""hi""ho""hu""ia""id""ie""ga""ig""ik""io""is""it""iu""ja""jv""kl""kn""kr""ks""kk""km""ki""rw""ky""kv""kg""ko""ku""kj""la""lb""lg""li""ln""lo""lt""lu""lv""gv""mk""mg""ms""ml""mt""mi""mr""mh""mn""na""nv""nb""nd""ne""ng""nn""no""ii""nr""oc""oj""cu""om""or""os""pa""pi""fa""pl""ps""pt""qu""rm""rn""ro""ru""sa""sc""sd""se""sm""sg""sr""gd""sn""si""sk""sl""so""st""es""su""sw""ss""sv""ta""te""tg""th""ti""bo""tk""tl""tn""to""tr""ts""tt""tw""ty""ug""uk""ur""uz""ve""vi""vo""wa""cy""wo""fy""xh""yi""yo""za"

Response Body

Boundaries contained by the requested place. An actual response can contain many features; examples are shortened. Empty features means no data for the request (see Deviation (empty)).

application/json
  1. response
type*unknown
features*array<>
Example Request
curl -X GET 'https://api.data.graphitelab.ai/v1/boundaries/consists-of?id=gp%3Aosm%3Ar161816&boundary=postal_code&sublevel=1&geometry=point&lang=en'
Example Response
{  "type": "FeatureCollection",  "features": [    {      "type": "Feature",      "properties": {        "name": "Adams County",        "country": "United States",        "continent": "North America",        "country_code": "us",        "state": "Indiana",        "state_code": "IN",        "iso3166_2": "US-IN",        "county": "Adams County",        "lon": -84.93671397818535,        "lat": 40.745785850000004,        "place_id": "gp:osm:r1797289",        "datasource": {          "sourcename": "openstreetmap",          "attribution": "© OpenStreetMap contributors",          "license": "Open Database License",          "url": "https://www.openstreetmap.org/copyright",          "raw": {            "osm_id": 1797289,            "osm_type": "r",            "admin_level": 6,            "wikidata": "Q351808",            "wikipedia": "en:Adams County, Indiana"          }        }      },      "geometry": {        "type": "Point",        "coordinates": [          -84.936714,          40.745786        ]      },      "bbox": [        -85.0738683,        40.568253,        -84.80217,        40.9225978      ]    },    {      "type": "Feature",      "properties": {        "name": "Allen County",        "country": "United States",        "continent": "North America",        "country_code": "us",        "state": "Indiana",        "state_code": "IN",        "iso3166_2": "US-IN",        "county": "Allen County",        "lon": -85.07039859151354,        "lat": 41.09943735,        "place_id": "gp:osm:r1527345",        "datasource": {          "sourcename": "openstreetmap",          "attribution": "© OpenStreetMap contributors",          "license": "Open Database License",          "url": "https://www.openstreetmap.org/copyright",          "raw": {            "osm_id": 1527345,            "osm_type": "r",            "admin_level": 6,            "wikidata": "Q493443",            "wikipedia": "en:Allen County, Indiana"          }        }      },      "geometry": {        "type": "Point",        "coordinates": [          -85.070399,          41.099437        ]      },      "bbox": [        -85.3381614,        40.9170272,        -84.8029428,        41.2711639      ]    }  ]}