I am trying to fetch zip code, city name and population in a single file from this api, But can't get it right.

Below one gives me population per city, but no zipcode


Below one gives population with zipcode, but no city name.


Basically what I want is to combine this two file, but couldn't manage it from the API doc

2 Answers 2


First a note. The US Census API provides data on zip code tabulation areas, not zip codes:

ZIP Code Tabulation Areas (ZCTAs) are statistical entities developed by the United States Census Bureau for tabulating summary statistics. [...] ZCTAs are generalized area representations of the United States Postal Service (USPS) ZIP code service areas, but are not the same as ZIP codes. Individual USPS ZIP codes can cross state, place, county, census tract, census block group and census block boundaries, so the Census Bureau asserts that "there is no correlation between ZIP codes and Census Bureau geography".


That said - is there any way to find out which zip code tabulation area belongs to which city? Yes.

You can download the relationship file here: https://www2.census.gov/geo/docs/maps-data/data/rel/zcta_place_rel_10.txt and then map on the response from the API.

An overview of available relationships can be found here: https://www.census.gov/geo/maps-data/data/zcta_rel_overview.html.

  • Honestly, you're right, several years ago when I was dealing with zip codes deeply I remember that one facet about them making it extra confusing by having ZCTAs. Upvoting.
    – Taal
    Jan 9, 2019 at 4:15

Looking at your question - zip codes and cities can overlap. Generally, in the US at least, zip codes are dictated and practically used by ups/fedex/usps.

I don't know how city borders are defined....and actually they are likely defined in many different ways (ie. a river or something), but I'm nearly positive zip codes and city borders are independent sets with correlational properties, but not identical properties. That's why you're seeing what you see.

Also keep in mind zip codes will change and modulate due to practicality for the post office. As the population density of areas for them to deliver stuff at changes, they will adapt to that, because zip codes have a true, practical, geospatial, purpose - city borders...not so much except for when certain applicable local city or county (which creates more overlap) has "noise level limits at x times" for instance.

  • 1
    Zip code tabulation areas are not the same as zip codes. Jan 8, 2019 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.