How to use http://www.census.gov API to pull data

倖福魔咒の 提交于 2019-12-06 02:49:37

问题


Am trying to query data from http://www.census.gov, using their API I want to get the population of a particular city in the US, by using the city name and the US state code.

Given that I already have the key, what other parameters do I add in the URL below, so that I can get the population.

http://api.census.gov/data/2010/sf1?key=<my key>

any assistance will be greatly appreciated


回答1:


Judging from your query URI, you wish to access population data from the 2010 Census Summary File. You would add GET paramaters of get and for to your query. Example:

http://api.census.gov/data/2010/sf1?key=b48301d897146e8f8efd9bef3c6eb1fcb864cf&get=P0010001&for=state:06

The population table as given in the get parameter are identified with a "P" and you can use the for parameter to further narrow down your scope. Examples of valid criteria formatted as URIs can be found here...

EDIT: It seems that for a finer grained search such as cities, you're going to need to use the governments cumbersome FIPS (Federal Information Processing Standard) codes (after converting lat/lon regions to their coding system)... I've found this resource that should be helpful, specifically points 5 thru 7, but it seems mega complex...

Another alternative I found is the USA Today census API, it seems that they mirror the data from the census and they do have available endpoints with data granularity at the city level... Check it out here...




回答2:


no need to use API the data is available in CSV here http://www.census.gov/popest/data/cities/totals/2012/SUB-EST2012.html



来源:https://stackoverflow.com/questions/19783792/how-to-use-http-www-census-gov-api-to-pull-data

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!