#Import modules
import requests
import json
import pandas as pd

#Set the key
key = None

"""
Explanation: Census REST interface
https://www.census.gov/data/developers/data-sets.html
End of explanation
"""


#Endpoint and payload
baseURL = 'https://api.census.gov/data/2015/acs5'
payload = {'get':'NAME,B01001_001E',
           'for':'county:*',
           'in':'state:37',
           'key':key
          }

response = requests.get(baseURL,payload)

t = response.text
c = response.content
print(type(t), type(c))

print t

"""
Explanation: American Community Survey 5-Year Data (2009-2015)
https://www.census.gov/data/developers/data-sets/acs-5year.html<br>
https://api.census.gov/data/2015/acs5/examples.html
End of explanation
"""


#Get list of variables
dfVars = pd.read_json('http://api.census.gov/data/2012/sbo')
dfVars.dataset.values[0]['description']

endpointURL = 'api.census.gov/data/2012/sbo'


"""
Explanation: 2012 Survey of Business Owners: Company Summary
https://www.census.gov/data/developers/data-sets/business-owners.html

Variables: api.census.gov/data/2012/sbo
End of explanation
"""


