List postcodes
Lists US ZCTA and Canadian FSA or full postal codes, filtered by prefix, shape or place and ordered by proximity.
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>.
text?stringPostcode prefix, matched case-insensitively with spaces and dashes ignored (46 -> 46201, K1A 0 -> K1A0A1). 1-1024 characters.
Deviation (approximated): prefix match on the code only, not free text.
1 <= length <= 1024filter?array<>Restrict results (ANDed). Values: rect:lon1,lat1,lon2,lat2, circle:lon,lat,radiusMeters, place:<place_id>.
Repeat the parameter or separate values with |. Applied to each postcode's representative point, not its area.
place: takes a Place ID as returned by this API (gp:pc:US-46204, gp:osm:r123). Invalid syntax or out-of-range coordinates return 400.
Deviation (approximated): point-in-shape tests, not area overlap; place: accepts our gp: IDs instead of Geoapify's hex IDs.
bias?array<>Order results without excluding any. Values: proximity:lon,lat (nearest first), circle:lon,lat,radiusMeters and
rect:lon1,lat1,lon2,lat2 (inside first). Repeat the parameter or separate values with |.
countrycode?stringISO 3166-1 alpha-2 country code, lower case. Only us and ca have data.
Deviation (unsupported): any other country returns an empty list.
"ad""ae""af""ag""ai""al""am""an""ao""ap""aq""ar""as""at""au""aw""az""ba""bb""bd""be""bf""bg""bh""bi""bj""bm""bn""bo""br""bs""bt""bv""bw""by""bz""ca""cc""cd""cf""cg""ch""ci""ck""cl""cm""cn""co""cr""cu""cv""cx""cy""cz""de""dj""dk""dm""do""dz""ec""ee""eg""eh""er""es""et""eu""fi""fj""fk""fm""fo""fr""ga""gb""gd""ge""gf""gg""gh""gi""gl""gm""gn""gp""gq""gr""gs""gt""gu""gw""gy""hk""hm""hn""hr""ht""hu""id""ie""im""il""in""io""iq""ir""is""it""je""jm""jo""jp""ke""kg""kh""ki""km""kn""kp""kr""kw""ky""kz""la""lb""lc""li""lk""lr""ls""lt""lu""lv""ly""ma""mc""md""me""mg""mh""mk""ml""mm""mn""mo""mp""mq""mr""ms""mt""mu""mv""mw""mx""my""mz""na""nc""ne""nf""ng""ni""nl""no""np""nr""nu""nz""om""pa""pe""pf""pg""ph""pk""pl""pm""pr""ps""pt""pw""py""qa""re""ro""rs""ru""rw""sa""sb""sc""sd""se""sg""sh""si""sj""sk""sl""sm""sn""so""sr""st""sv""sy""sz""tc""td""tf""tg""th""tj""tk""tm""tn""to""tr""tt""tv""tw""tz""ua""ug""um""us""uy""uz""va""vc""vg""ve""vi""vn""vu""wf""ws""ye""yt""za""zm""zw"limit?integerMaximum number of results, 1-500.
1 <= value <= 5005offset?integerNumber of results to skip, for paging. 0 or more.
0 <= value0lang?stringTwo-letter language code. Affects only the state name (falls back to the default name when the boundary has no name in that language); formatted follows it.
Deviation (approximated): country names are always English.
"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"format?stringResponse format. geojson (default) returns application/geo+json; json returns {results: [...]} of the same properties; xml returns the json structure as XML.
"geojson""json""geojson""xml"geometry?stringpoint (default) or original (area polygon, only for format=geojson, only ZCTA5/FSA results; 6-character Canadian codes stay points).
Deviation (approximated): original is the Census/StatCan boundary, full detail.
"point""point""original"Matching postcodes (an empty list when none match). datasource on each result is described under the schema.
- response
type*unknownfeatures*array<>curl -X GET 'https://api.data.graphitelab.ai/v1/postcode/list?text=462&filter=circle%3A-86.158%2C39.768%2C3000&bias=proximity%3A-75.697%2C45.4215&countrycode=us&limit=2&offset=0&lang=en&format=geojson&geometry=point'{ "results": [ { "datasource": { "sourcename": "statcan-fsa", "attribution": "© Statistics Canada, Forward Sortation Area Boundary File", "url": "https://www12.statcan.gc.ca/census-recensement/2021/geo/sip-pis/boundary-limites/index2021-eng.cfm" }, "postcode": "K1A", "ref": "K1A", "country": "Canada", "continent": "North America", "country_code": "ca", "state": "Ontario", "state_code": "ON", "iso3166_2": "CA-ON", "lon": -75.61867714803402, "lat": 45.44306, "formatted": "K1A, Ontario, Canada", "result_type": "postcode", "place_id": "gp:pc:CA-K1A" }, { "datasource": { "sourcename": "statcan-nar", "attribution": "© Statistics Canada, National Address Register (postal code centroids derived from address points)", "url": "https://www.statcan.gc.ca/en/lode/databases/nar" }, "postcode": "K1A 0A1", "ref": "K1A 0A1", "country": "Canada", "continent": "North America", "country_code": "ca", "state": "Ontario", "state_code": "ON", "iso3166_2": "CA-ON", "lon": -75.685842, "lat": 45.443892, "formatted": "K1A 0A1, Ontario, Canada", "result_type": "postcode", "place_id": "gp:pc:CA-K1A0A1" } ]}Full schema: API reference
GET /v1/postcode/list returns postcodes for the United States and Canada. Narrow them with a code prefix (text), spatial or place filters and a country, order them with bias, and page with limit and offset. Use it to find which postcodes fall inside a circle, rectangle or another postcode area, or to autocomplete a code prefix. For a single lookup by code or coordinates, see Postcode search.
How it works
No Waterfall or routing Engine is involved. The gateway answers from one indexed PostGIS table (gateway.postcode_index) in the Nominatim Postgres cluster, as one SQL query with your filters, bias ordering and paging applied. It is the same data as /postcode/search.
| Country | Data | datasource.sourcename |
|---|---|---|
| US | Census ZCTA5 areas | census-zcta5 |
| Canada, 3 characters | StatCan Forward Sortation Area (FSA) areas | statcan-fsa |
| Canada, 6 characters | Centroid points derived from the StatCan National Address Register (NAR) | statcan-nar |
state, state_code and iso3166_2 come from the OSM state or province boundary covering the postcode's point. Postcode results themselves are never OSM-derived.
Quick start
curl -s "https://api.data.graphitelab.ai/v1/postcode/list?filter=circle:-86.158,39.768,3000&countrycode=us&limit=2&apiKey=$GRAPHITE_API_KEY"ZCTA5 areas within 3 km of downtown Indianapolis (trimmed to the first result):
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"datasource": {
"sourcename": "census-zcta5",
"attribution": "US Census Bureau, TIGER/Line ZIP Code Tabulation Areas",
"url": "https://www.census.gov/programs-surveys/geography/guidance/geo-areas/zctas.html"
},
"postcode": "46202",
"ref": "46202",
"distance": 2016,
"country": "United States",
"continent": "North America",
"country_code": "us",
"state": "Indiana",
"state_code": "IN",
"iso3166_2": "US-IN",
"lon": -86.1752756520431,
"lat": 39.7803265,
"formatted": "46202, Indiana, United States",
"result_type": "postcode",
"place_id": "gp:pc:US-46202"
},
"geometry": {
"type": "Feature",
"properties": {},
"geometry": { "type": "Point", "coordinates": [-86.1752756520431, 39.7803265] }
},
"bbox": [-86.1752756520431, 39.7803265, -86.1752756520431, 39.7803265]
}
]
}Parameters
| Name | Type | Required | What it does |
|---|---|---|---|
text | string (1-1024 chars) | no | Case-insensitive prefix match on the code, ignoring spaces and dashes (46 matches 46201, K1A 0 matches K1A0A1). Not free text; does not match place names. |
filter | array of strings | no | Restrict results, ANDed: rect:lon1,lat1,lon2,lat2, circle:lon,lat,radiusMeters, place:<place_id>. Repeat the parameter or separate values with |. Tests each postcode's representative point, not its area. |
bias | array of strings | no | Order results without excluding any: proximity:lon,lat (nearest first), circle:lon,lat,radiusMeters or rect:lon1,lat1,lon2,lat2 (inside first). |
countrycode | string | no | Lower-case ISO 3166-1 alpha-2 code. Only us and ca have data; other valid codes return an empty list, unknown codes return 400. |
limit | integer, 1-500 | no | Maximum results. Default 5. |
offset | integer, 0 or more | no | Results to skip, for paging. Default 0. There is no total count. |
lang | string | no | Two-letter language code. Affects only the state name (and formatted). Default en. |
format | json, geojson, xml | no | Default geojson (application/geo+json). json returns {results: [...]}; xml is the same structure as XML. |
geometry | point, original | no | point (default) or original for the full-detail ZCTA5/FSA polygon. Only affects format=geojson. |
Response
Each result has these fields in properties (or directly on each item with format=json):
| Field | Meaning |
|---|---|
postcode / ref | The code. Canadian 6-character codes include the space (K1A 0A1). |
place_id | Readable typed ID gp:pc:<COUNTRY>-<code>, for example gp:pc:US-46204 or gp:pc:CA-K1A0A1 (ADR 0006). Accepted by filter=place:. |
datasource | sourcename, attribution and url of the source (see table above). Include the attribution when you display results. |
distance | Meters from the circle center or proximity point. Present only when a circle filter or proximity bias is given. |
lon, lat | Representative point: a point inside the area for ZCTA/FSA, the centroid for NAR. |
state, state_code, iso3166_2 | From the OSM state or province boundary covering the point. |
result_type | Always postcode. |
With geometry=point the GeoJSON feature holds a nested Feature with the Point and a degenerate bbox. With geometry=original it holds the Polygon or MultiPolygon and its real bbox; 6-character Canadian codes have no polygon and stay points. Polygons can be large, so keep limit small. There is no rank on this endpoint.
Differences from Geoapify
-
empty: Address-component, timezone and
plus_codefields (city,district,suburb,county,timezone,plus_code,address_line1, ...) are never returned; only the fields in the schema are emitted. -
extra:
place_idis the readablegp:pc:<COUNTRY>-<code>format. Geoapify place IDs are not accepted. -
unsupported: Coverage is US and Canada only; other country codes return no results.
-
approximated (
text): Prefix match on the code only, not free-text search. -
approximated (
filter):rect,circleandplacetest the postcode's representative point, not area overlap;place:takes ourgp:IDs (gp:pc:*andgp:osm:*), and an unknown ID matches nothing. -
approximated (
geometry):originalreturns the ZCTA5/FSA boundary at full detail; 6-character Canadian codes have no polygon. -
approximated (
lang): Only thestatename is localized; country names are always English.
US and Canada notes
-
A ZCTA is not a USPS ZIP. PO-box-only ZIPs have no area and are not listed.
-
Canada returns two kinds of results: 3-character FSAs (areas) and full 6-character postal codes (centroid points from the NAR). A
textprefix such asK1Areturns both, areas first, then 6-character codes, then by code. -
Several
biasvalues apply in the order given. -
statecomes from the OSM boundary covering the point;langlocalizes its name, falling back to the default name when none exists.
More examples
ZIP 46204 with its full-detail boundary instead of a point.
curl -s "https://api.data.graphitelab.ai/v1/postcode/list?text=46204&countrycode=us&limit=1&geometry=original&apiKey=$GRAPHITE_API_KEY"Errors and limits
| Status | Meaning |
|---|---|
400 | Invalid parameter, such as bad filter/bias syntax, out-of-range coordinates, limit/offset out of range, or a value outside the enums for countrycode, lang, format or geometry. |
401 | Missing or invalid API key. |
500 | Internal error. |
limit is 1-500 (default 5), offset is 0 or more, text is 1-1024 characters. An empty match returns a 200 with an empty list.
Phase 18 testing found no known gateway bugs affecting /postcode/list. One related caveat: /geocode/reverse with type=postcode currently keeps the building node's place_id, bbox and distance instead of the postcode's.
Try in Playground (signed in to your Graphite Lab organization). Signed out, use the paste-your-key widget on the reference page.