census.py 511 B

1234567891011121314151617181920
  1. '''
  2. Module containing a handful of methods for
  3. aggregating U.S. Census data.
  4. '''
  5. import requests
  6. import simplejson as json
  7. ########################
  8. # CENSUS API CONSTANTS #
  9. ########################
  10. API_BASE_URL = 'http://api.census.gov/data/2013/pep/natstprc'
  11. def getPopulationEstimate(url):
  12. req = requests.get(url)
  13. #print len(req.text)
  14. print req.text
  15. getPopulationEstimate('http://api.census.gov/data/2013/pep/monthlynatchar5?get=AGE,SEX,DATE,RACE5,HISP&key=1286203d2772de1f09f13392cc42a0197b2cd414')