Skip to content

US Geography API

ZIP code in, place and county and coordinates out: 40,977 US ZIP codes, 3,245 county FIPS codes and 57 state FIPS codes from GeoNames and the US Census Bureau.

API key required OpenAPI API conventions

A ZIP code to county, place and coordinates lookup for the United States. Give it a five-digit ZIP code and it returns the place name, the two-letter state code, the five-digit county FIPS code and a WGS84 latitude and longitude. It holds 40,977 ZIP codes across the 50 states and the District of Columbia, 3,245 counties and county equivalents, and 57 state, district and territory FIPS codes.

Sources and licences. Postal codes, place names and coordinates are built from data © GeoNames (https://www.geonames.org), used under the Creative Commons Attribution 4.0 International licence (https://creativecommons.org/licenses/by/4.0/). A link to GeoNames is all the licence asks for, and it is given here and on every page this dataset appears on. County and state FIPS codes and official county names come from the US Census Bureau's 2020 national county file and its state code file (www2.census.gov/geo/docs/reference); those are works of the United States government and are in the public domain, so no attribution is required for them, though the files are named here anyway.

How it is normalised. The large table stores codes and nothing else — state_code as CHAR(2), county_fips as CHAR(5), coordinates as fixed-point DECIMAL rather than floats — and the readable state and county names are joined in from the states and counties collections, so "Connecticut" is stored once instead of once per ZIP code. The ZIP code itself is the primary key, so looking one up needs no secondary index at all, and only state_code and county_fips carry one — which is why the whole dataset costs single-digit megabytes. place_name is free-text searchable with the q parameter instead of indexed. Each state row carries county_count and zip_count, and each county row carries zip_count, so a caller never needs an aggregate query to size a result first.

Three questions, one request each. A ZIP code latitude longitude and county lookup: GET /v1/geo/postal-codes/10001 returns place_name "New York", state_code "NY", county_fips "36061", latitude 40.74840 and longitude -73.99670, with state_name and county_name resolved alongside. Every ZIP code in a county: GET /v1/geo/postal-codes?county_fips=36061&limit=200. ZIP codes whose place name matches a term inside one state: GET /v1/geo/postal-codes?state_code=NY&q=brook. A FIPS code lookup on its own is GET /v1/geo/counties/36061 or GET /v1/geo/counties?state_code=NY.

Where the two registers disagree. GeoNames county codes were checked against the Census register row by row: 40,558 matched and 419 did not, across 10 distinct codes — Connecticut's nine planning regions (09110 to 09190, which replaced that state's counties and are absent from the 2020 county file) and one retired Alaska borough code. Those 10 county equivalents are published in /counties with source "geonames" rather than "census", so every county_fips in /postal-codes resolves and no row claims an authority it does not have. Military APO and FPO ZIP codes are not included: the source carries no state or county for them and places them at overseas duty stations. Puerto Rico and the other territories appear in /states and /counties with their FIPS codes, but GeoNames publishes their postal codes in separate country files that are not loaded here, so their zip_count is 0. Re-running the seeder refreshes everything; GeoNames rebuilds the postal export daily and the Census code files change with each decennial vintage.

Calls need a Bodek API key; create one at https://api.bodek.us/keys.

Every call needs a key. Sign in to create one. Bodek API is included with the plans that cover it.

Endpoints

GET /v1/geo/states States
GET /v1/geo/states/{id} A single record
GET /v1/geo/counties Counties
GET /v1/geo/counties/{id} A single record
GET /v1/geo/postal-codes Postal codes
GET /v1/geo/postal-codes/{id} A single record

Try it

https://api.bodek.us/v1/geo/states?limit=5

        
      

This panel sends no key, so it answers 401 — it is here to show you the shape of a request and the error envelope. Use curl with your own key to see data.

States

The 57 US states, the District of Columbia and the territories, with USPS code, Census FIPS code and name.

FieldTypeDescriptionFilterSearchSort
code string USPS two-letter abbreviation and the identifier for this record, e.g. "NY". Addressable as /v1/geo/states/NY.
fips string Census state FIPS code, two digits with the leading zero kept, e.g. "36" for New York and "06" for California. The first two digits of every county FIPS code in this state.
name string Official name from the Census state file, e.g. "New York" or "District of Columbia". Searchable with q; filter by code instead.
county_count integer How many rows this state has in /v1/geo/counties, e.g. 62 for NY.
zip_count integer How many rows this state has in /v1/geo/postal-codes, e.g. 2154 for NY. Zero for the territories, whose postal codes GeoNames publishes in separate files that are not loaded here.
curl "https://api.bodek.us/v1/geo/states?limit=5&fips=example&q=search+text" \
  -H "Authorization: Bearer $BODEK_API_KEY"

Counties

FIPS code to county name and state: 3,235 counties and county equivalents from the 2020 Census register, plus 10 GeoNames-only county equivalents.

FieldTypeDescriptionFilterSearchSort
fips string Five-digit county FIPS code and the identifier for this record: state FIPS then county FIPS, leading zeros kept, e.g. "36061" for New York County. Addressable as /v1/geo/counties/36061.
state_code string USPS code of the state this county is in, e.g. "NY". Filter on this to list a state's counties.
state_name string Full state name, joined from /v1/geo/states, e.g. "New York".
name string County name as the source spells it, e.g. "New York County", "St. Louis city" or "Doña Ana County". Searchable with q; filter by fips or state_code instead.
class_code string Census CLASSFP class code, e.g. "H1" for an active county, "C7" for an independent city. Null for a row that is not in the Census file.
source string Which register this row comes from: "census" for the 2020 Census county file, or "geonames" for a county equivalent GeoNames uses that the Census file does not list, such as Connecticut's planning region 09110.
zip_count integer How many rows in /v1/geo/postal-codes carry this county_fips, e.g. 146 for 36061.
curl "https://api.bodek.us/v1/geo/counties?limit=5&state_code=example&q=search+text" \
  -H "Authorization: Bearer $BODEK_API_KEY"

Postal codes

40,977 US ZIP codes with place name, state, county FIPS code and WGS84 coordinates, filterable by zip, state_code and county_fips.

FieldTypeDescriptionFilterSearchSort
zip string Five-digit ZIP code as text, leading zeros kept, e.g. "01001" or "10001", and the identifier for this record: GET /v1/geo/postal-codes/10001. Also filterable: zip=10001, or zip__in=10001,10002,10003.
place_name string Place GeoNames associates with this ZIP code, e.g. "New York" or "Holyoke". Searched with q (q=brook), not filtered — combine it with state_code to scope the search.
state_code string USPS two-letter state code, e.g. "NY". Filter with state_code=NY.
state_name string Full state name, joined from /v1/geo/states, e.g. "New York".
county_fips string Five-digit county FIPS code: the state FIPS code plus the county code GeoNames gives, e.g. "36061". Filter with county_fips=36061 to list every ZIP code in a county. Null when the source gives no county code.
county_name string County name, joined from /v1/geo/counties, e.g. "New York County".
latitude number WGS84 latitude of the ZIP code centroid, five decimal places, e.g. 40.74840. Null when the source coordinate is missing or falls outside plausible US bounds.
longitude number WGS84 longitude of the ZIP code centroid, five decimal places, e.g. -73.99670. Null on the same terms as latitude.
accuracy integer How GeoNames derived the coordinate: 1 estimated, 4 from a GeoNames place, 6 from an address or shape centroid. e.g. 4. Null when the source leaves it blank.
curl "https://api.bodek.us/v1/geo/postal-codes?limit=5&state_code=example&q=search+text" \
  -H "Authorization: Bearer $BODEK_API_KEY"

Common questions

How do I get access to the US Geography API?

Bodek API is included with the Bodek plans that cover it. Sign in, create a key on the keys page, and send it as an Authorization: Bearer header. A key is scoped to the APIs you pick, carries its own rate limits and expiry, and can be revoked at any time.

What format does it return?

JSON over HTTPS, one GET per collection, with the same filtering, search, sort and paging conventions on every endpoint. An OpenAPI 3.1 description is published at https://api.bodek.us/v1/geo/openapi.json.

How often does the data change?

It is maintained as production reference data, and responses carry an ETag so an unchanged request comes back as an empty 304. This API was last updated on 26 October 2026.

Limits

  • Up to 200 records per request (limit), 50 by default.
  • Rate limits are set per key, up to 600 requests a minute.
  • Responses are cached for up to 3600 seconds and carry an ETag.