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

Tags

Submitted by

Stage: Active

Feedback Score

1 vote
1 up votes
0 down votes
Idea#72

Idea Details

Vote Activity

  1. Upvoted

Similar Ideas [ 4 ]

Events

  1. The idea was posted

Comments

  1. Comment
    Community Member

    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.

  2. Comment
    Phillip Thomas

    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.

  3. Comment
    Community Member

    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.

  4. Comment
    Phillip Thomas

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

  5. Comment
    Community Member

    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.

  6. Comment
    raymondcamden

    The state list link given below is no longer working. What is the proper link?

  7. Comment
    raymondcamden

    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=*

Add your comment