Vote up to Idea Problem with List of State Codes and Zip Code Search Vote down to Idea Problem with List of State Codes and Zip Code Search

Rank 94

Idea#72

This idea is active.
Using Data »

Problem with List of State Codes and Zip Code Search

I'm trying to retrieve the population for a certain zip code.

What I found in your online documentation is that I should use the following URL string:

http://api.census.gov/data/2010/sf1?key=(key)&get=P0010001&for=zip+code+tabulation+area:(zip)&in=state:(state)

...where (key) is my API key, (zip) is the zip code, and (state) is a two digit code that you use to identify states.

The problem that I run into is that I cannot find a correct list of states and their corresponding two digit codes. What is particularly frustrating is that you have a list posted at the following address which seems like it provides the two digit codes for states. However the two digit codes on the list at this link do not match up to the data output by the above API URL.

http://www.census.gov/govs/www/gidstate.html

What gives? Is the API not working properly for this type of search? If it is working properly then where can I find the REAL state code list?

Also, why won't the API return a query like the following, where I could just search by zip code for all states?

http://api.census.gov/data/2010/sf1?key=(key)&get=P0010001&for=zip+code+tabulation+area:(zip)&in=state:*

Thanks

Comment

Submitted by 1 year ago

Comments (12)

  1. Moderator

    You can use this link to get place codes to use for differnt geography. http://www.census.gov/geo/reference/ansi.html State codes are at http://www.census.gov/geo/www/ansi/statetables.html

    1 year ago
    1. mnutsch Idea Submitter

      This link provided by Lisa W solved the issue that I had.

      http://www.census.gov/geo/www/ansi/statetables.html

      Thank you!

      1 year ago
  2. 1) The Census 2010 ZCTA 871 API call works correctly as described in my experience.

    2) The state code list link that you mention is correct; these are the state FIPS codes; lead zeroes as applicable (in the state 2 digit FIPS value) must be in your API call; eg 06 for CA, not just 6.

    3) It would be desirable to have an all US wildcard Census 2010 ZCTA 871 API call; there is an all US wildcard ACS 2011 860 call; it works correctly.

    1 year ago
  3. Another problem that may be blocking the original query is that state may or may not be enabled to use a wildcard for performance reasons. The more data the API has to return, the slower it can become.

    1 year ago
  4. The state code is often not used with ZCTA data by Census or otherwise. In a very few cases, ZCTAs cross state boundaries. The state code is omitted in the Census ZCTA Gazetteer file, ZCTA TIGER shapefiles, and otherwise.

    1 year ago
  5. This particular case (Decennial SF1) does have this rolling up into state which is an odd thing, but something they decided to do.

    1 year ago
  6. SF1 is the exception and rolls to state to enable getting ZCTA parts since each ZCTA is comprised of a set of blocks (which can be in different states); hence a difference in summary level 860 and 871.

    1 year ago
  7. The state list link given below is no longer working. What is the proper link?

    1 year ago
  8. Thank you.

    1 year ago
  9. I hate to pollute a thread w/ an off topic question, but is there an easy way to get state data for all w/o passing all the codes? Basically state=*

    1 year ago
  10. Wow, state=* worked. That was easy.

    1 year ago

Vote Activity Show

Events

  1. The idea was posted
    1 year ago