hrecht / censusapi

R package to retrieve U.S. Census data and metadata via API
https://www.hrecht.com/censusapi/
169 stars 31 forks source link

error retrieving 2016 ACS #33

Closed andrewbreck closed 6 years ago

andrewbreck commented 6 years ago

I obtain an error when retrieving 2016 5 year ACS estimates (code and error are below).

I believe the issue is because the api url for the 2016 data is slightly different that prior years. For example, urls for one variable from one state in 2015 and 2016 are, respectively: https://api.census.gov/data/2015/acs5?get=NAME,B02001_001E&for=tract:*&in=state:04 https://api.census.gov/data/2016/acs/acs5?get=NAME,B02001_001E&for=tract:*&in=state:04

test2016 <- getCensus(name="acs5", vintage=2016, vars="B02001_001E", region="tract:*", regionin="state:06")

Error in apiParse(req) : API response is not JSON Error message: Error report HTTP Status 404 - /data/2016/acs5type Status reportmessage /data/2016/acs5description The requested resource is not available.

hrecht commented 6 years ago

Hello - the ACS indeed changed the URL endpoint for recent ACS data. It's now prefixed with "acs/"

To get the 2016 data, use:

test2016 <- getCensus(name="acs/acs5", 
vintage=2016, vars="B02001_001E", region="tract:*", regionin="state:06")