Skip to content
yangxu edited this page Apr 30, 2015 · 8 revisions

data_adapter.py

data(self, formula, geo_record, **kwargs):

This function will break your formula to parts. If formula = "P0120018+P0120019", then parser to [P0120018, P0120019]. LOOP [part1, part2....partn] to get_api_data(self, part, geo_record) return val

get_api_data(self, table, geo_record):

This function will build the API calls such as url, api_key, params Example such as url = http://api.census.gov/data/2010/sf1? params = {'key':your API key, 'get':table, 'for':'county+subdivision:003', 'in':'state:02+county:29'} call get(self, url, params={}) return val

get(self, url, params={}):

make this call http://api.census.gov/data/2010/sf1?get=P0010001&for=county+subdivision:003&in=state:02+county:29 return val

About the Quick Stats API http://quickstats.nass.usda.gov/api

The QuickStats API has three resources, but we only used one. GET /api/api_GET: accepts a combination of "WHAT" and/or "WHERE and/or "WHEN" parameters and return maximum of 50K records http://quickstats.nass.usda.gov/api/api_GET/?key=api key&{parameter ... parameter}&format={json | csv | xml}&callback={function name}

About the Bureau of Labor Statistics API http://www.bls.gov/developers/

The BLS Public Data API is currently available in two versions. We only use V2 to access data. Seriesid will be used as formula.

HTTP Type: POST URL: http://api.bls.gov/publicAPI/v2/timeseries/data/ Payload: JSON Payload: {"seriesid":["Series1",..., "SeriesN"], "startyear":"yearX", "endyear":"yearY", "catalog":true|false, "calculations":true|false, "annualaverage":true|false, "registrationKey":"995f4e779f204473aa565256e8afe73e" } Example Payload: {"seriesid":["LAUCN040010000000005", "LAUCN040010000000006"], "startyear":"2010", "endyear":"2012", "catalog":false, "calculaltions":true, "annualaverage":true, "registrationKey":"995f4e779f204473aa565256e8afe73e" }

Daily query limit for BLS are 500