Boundaries consists-of
Lists the child boundaries (counties, townships, postal code areas) that sit inside a parent boundary.
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.
apiKey<token>Your API key from the dashboard, sent as ?apiKey=<key>.
id*stringPlace 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
3 <= length <= 2048boundary?stringBoundary 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).
"administrative""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?integerNested 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.
1 <= value <= 201geometry?stringGeometry 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.
"point""point""geometry_1000""geometry_5000""geometry_10000"lang?stringLanguage used for boundary names and address fields (falls back to the default OpenStreetMap name when a boundary has no name in that language).
"en""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"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- response
type*unknownfeatures*array<>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'{ "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 ] } ]}Full schema: API reference
GET /v1/boundaries/consists-of takes the Place ID of a boundary and returns the boundaries contained inside it, as a GeoJSON FeatureCollection. Use it to list the counties of a state, the subdivisions of a province, or the postal code areas inside a county. Get the parent id from /boundaries/part-of (the properties.place_id of the boundary you want).
How it works
The gateway answers this route with SQL only: no Geocoding Waterfall, Valhalla or VROOM.
- The
idis decoded and resolved to a parent geometry.gp:osm:...ids look up the OpenStreetMap boundary in the Nominatimplacextable;gp:pc:...ids look up a postal polygon. - For
boundary=administrative, it selects OpenStreetMap administrative boundaries (admin_level2 to 11) that are deeper than the parent and whose representative point lies inside the parent.sublevelpicks the N-th distinctadmin_levelfound below the parent. - For
boundary=postal_code, it selects ZCTA5 polygons (US, Census) or FSA polygons (Canada, Statistics Canada) whose representative point lies inside the parent. - Results are ordered by name (administrative) or code (postal). Polygon geometry is simplified with PostGIS
ST_SimplifyPreserveTopology.
Administrative data comes from the Geofabrik US and Canada OpenStreetMap extract, loaded through Nominatim.
Quick start
All of Indiana's counties:
curl -s "https://api.data.graphitelab.ai/v1/boundaries/consists-of?id=gp:osm:r161816&apiKey=$GRAPHITE_API_KEY"Response (trimmed to the first feature of 92):
{
"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]
}
]
}Parameters
| Name | Type | Required | What it does |
|---|---|---|---|
id | string (3 to 2048 chars) | yes | Place ID of the parent boundary, as returned in properties.place_id. Formats: gp:osm:<n|w|r><osm id> or gp:pc:<US-ZIP|CA-FSA>. A malformed id returns 400. |
boundary | string enum, default administrative | no | Boundary type to return. Only administrative and postal_code have data. |
sublevel | integer 1 to 20, default 1 | no | Nested depth. Counts distinct admin_level values below the parent. For postal_code, only 1 returns data. |
geometry | enum point, geometry_1000, geometry_5000, geometry_10000, default point | no | point returns representative points. The geometry_* values return simplified Polygon or MultiPolygon geometry at that accuracy in meters. |
lang | two-letter code, default en | no | Language for boundary names; falls back to the default OpenStreetMap name. |
Response
A GeoJSON FeatureCollection. Each feature has properties, geometry and bbox.
place_id: opaque string of the formgp:<kind>:<key>. Administrative features usegp:osm:r161816; postal features usegp:pc:US-46201. Pass it back asidto walk down another level.name,country,country_code,state,state_code,iso3166_2,countyand similar address fields describe the boundary and its parents.lonandlat: the boundary's representative point.datasource: where the boundary came from. OpenStreetMap boundaries cite "© OpenStreetMap contributors" under the Open Database License. Postal features usecensus-zcta5orstatcan-fsaand cite their source.datasource.raw: source identifiers. Administrative features carryosm_id,osm_type,admin_leveland, when present,wikidata,wikipedia,ISO3166-2. Postal features carrycode.- Postal features also carry
postcodeandpostal_code. geometry: a Point by default, or a simplified Polygon or MultiPolygon withgeometry_*.
This endpoint has no rank field and no distances or times.
Differences from Geoapify
-
empty: only
administrativeandpostal_codeboundaries have data. Otherboundaryvalues, unknown ids and non-boundary Place IDs (gp:addr,gp:tz,gp:iso) return an empty FeatureCollection, not 404. Other boundary types also set theX-Boundaries-Noteresponse header: "consists-of has data for administrative and postal_code only". -
extra:
datasource.rawis a small set of source identifiers instead of the full OpenStreetMap tag set, and many optional Geoapify properties (formatted,categories,website,name_international,timezoneand others) are not populated. Postal features addpostcodeandpostal_code. -
approximated:
sublevelcounts distinctadmin_levelvalues present below the parent, not parent level plus N. Containment is decided by each child's representative point, not by polygon overlap.
Geoapify's own place ids are not understood; use ids returned by this API.
US and Canada notes
- US postal results are Census ZCTA5 polygons, which approximate ZIP codes. PO-box-only ZIPs have no polygon.
- Canadian postal results are FSA polygons (the first three characters of a postal code), from Statistics Canada.
- OpenStreetMap admin levels are sparse and differ by region. Indiana's counties are level 6; Ontario's children come back as OpenStreetMap subdivisions such as "Central Ontario". Use
sublevelto step down. - Names follow
lang. Ask forfrto get French names where OpenStreetMap has them.
More examples
Administrative boundaries below Ontario, Canada.
curl -s "https://api.data.graphitelab.ai/v1/boundaries/consists-of?id=gp:osm:r68841&apiKey=$GRAPHITE_API_KEY"Errors and limits
| Status | Meaning |
|---|---|
| 200 | FeatureCollection, possibly empty. |
| 400 | Missing id, malformed id, or invalid boundary, sublevel, geometry or lang. |
| 401 | Missing or invalid credentials. |
| 500 | Internal error. |
| 503 | Service unavailable. |
Limits: id is 3 to 2048 characters, and sublevel is 1 to 20.
Known issue: this endpoint takes about 11.5 seconds per call in production. It runs a full administrative scan of the placex table with no bounding-box prefilter. Set a generous client timeout.
Try in Playground (signed in to your Graphite Lab organization). Signed out, use the paste-your-key widget on the reference page.