Postcode

List postcodes

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
/postcode/list

Lists postcodes, optionally narrowed by a code prefix (text), spatial or place filters and a country, with bias ordering and limit/offset paging. Coverage is the United States and Canada only.

Data. US: Census ZCTA5 areas (a ZCTA is not a USPS ZIP: PO-box-only ZIPs have no area and are not listed). Canada: StatCan Forward Sortation Area (FSA, 3 characters) areas plus full 6-character postal codes as centroid points derived from the National Address Register. Same data as /postcode/search. Each result's datasource names its source (census-zcta5, statcan-fsa, statcan-nar) with that source's attribution. Postcode results are never OSM-derived.

Matching and limits.

  • text is a case-insensitive prefix match on the code with spaces and dashes removed (k1a 0 matches K1A0A1). It is not full-text search and does not match place names.
  • filter conditions are ANDed. rect and circle test each postcode's representative point (a point inside the area for ZCTA/FSA, the centroid for NAR), not area overlap. place:<place_id> keeps postcodes whose point lies inside that place's boundary and accepts gp:pc:* (ZCTA/FSA area) and gp:osm:* (OSM boundary) IDs; an unknown or unsupported ID matches nothing.
  • bias orders results without excluding any. Several biases apply in the order given, then areas (ZCTA/FSA) before 6-character codes, then by code.
  • limit is 1-500 (default 5); offset is 0 or more. There is no total count.
  • distance is returned only when a circle filter or proximity bias is given.

Geometry. geometry=point (default) returns a nested Feature holding the representative Point, and a degenerate bbox. geometry=original returns the full-detail (unsimplified) Polygon/MultiPolygon and its bbox for ZCTA5 and FSA results; full 6-character Canadian codes have no polygon and stay points. Polygons can be large: keep limit small. geometry only affects format=geojson.

Deviation (empty): Geoapify's address-component and enrichment fields (city, district, suburb, county, timezone, plus_code, plus_code_short, address_line1, address_line2, ...) are never returned. state, state_code and iso3166_2 come from the OSM state/province boundary covering the postcode's point.

Deviation (extra): place_id uses our readable typed format gp:pc:<COUNTRY>-<code> (for example gp:pc:US-46204, gp:pc:CA-K1A0A1), not Geoapify's opaque ID. Geoapify place IDs are not accepted.

Not supported: none; every Geoapify parameter of this endpoint is read. countrycode is accepted for any country in Geoapify's list but only us and ca have data, so other values return an empty list.

Authorization

queryapiKey<token>

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

Query Parameters

text?string

Postcode 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.

Length1 <= length <= 1024
filter?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?string

ISO 3166-1 alpha-2 country code, lower case. Only us and ca have data. Deviation (unsupported): any other country returns an empty list.

Value in"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?integer

Maximum number of results, 1-500.

Range1 <= value <= 500
Default5
offset?integer

Number of results to skip, for paging. 0 or more.

Range0 <= value
Default0
lang?string

Two-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.

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"
format?string

Response format. geojson (default) returns application/geo+json; json returns {results: [...]} of the same properties; xml returns the json structure as XML.

Default"geojson"
Value in"json""geojson""xml"
geometry?string

point (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.

Default"point"
Value in"point""original"

Response Body

Matching postcodes (an empty list when none match). datasource on each result is described under the schema.

  1. response
type*unknown
features*array<>
Example Request
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'
Example Response
{  "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"    }  ]}