CenterOnBudget / getcensus

Load American Community Survey data from the U.S. Census Bureau API into Stata
https://centeronbudget.github.io/getcensus/
MIT License
14 stars 3 forks source link

keep getting "could not open the url", with a valid api-key #59

Closed StephanieUB closed 1 year ago

StephanieUB commented 2 years ago

Describe the bug keep getting "could not open the url", with a valid api-key

To Reproduce getcensus B19013, geography(zcta) sample(5) clear

Code snippet to reproduce the behavior (be sure to redact your API key) Stata version (17) and operating system ( Windows)

error message: remote connection failed could not open url The Census Bureau API did not return data for 2019. This may have happened because: • Table ID or variable IDs are invalid or are not available for the requested year. • API key is invalid. • Problems with your internet connection. To see the error message returned by the Census Bureau API, click here.

(Clicking the generated link(https://api.census.gov/data/2020/acs/acs5/subject?get=group(S2701)NAME&for=state:*&key=fd64267ada1), I do get the json file ><)

Expected behavior A clear and concise description of what you expected to happen.

StephanieUB commented 2 years ago

Describe the bug keep getting "could not open the url", with a valid api-key

To Reproduce getcensus B19013, geography(zcta) sample(5) clear

Code snippet to reproduce the behavior (be sure to redact your API key) Stata version (17) and operating system ( Windows)

error message: remote connection failed could not open url The Census Bureau API did not return data for 2019. This may have happened because: • Table ID or variable IDs are invalid or are not available for the requested year. • API key is invalid. • Problems with your internet connection. To see the error message returned by the Census Bureau API, click here.

(Clicking the generated link(https://api.census.gov/data/2020/acs/acs5/subject?get=group(S2701)NAME&for=state:*&key=fd64267ada1), I do get the json file ><)

Expected behavior A clear and concise description of what you expected to happen.

I also tried this code : getcensus DP05, years(2020) geography(tract) statefips(1) sample(5) noerror clear

and getting this error message: remote connection failed could not open url The Census Bureau API did not return data for 2020. This may have happened because: • Table ID or variable IDs are invalid or are not available for the requested year. • API key is invalid. • Problems with your internet connection. To see the error message returned by the Census Bureau API, click here.

and return this link: https://api.census.gov/data/2020/acs/acs5/profile?get=group(DP05)NAME&for=tract:*&in=state:1&key=fd64a1

c-zippel commented 1 year ago

Hi @StephanieUB,

Apologies for the late response.

Re: your first message - the following code works for me: getcensus B19013, geography(zcta) sample(5) year(2019) clear. It looks like you also tried getcensus S2701, sample(5) year(2020) clear, which also works for me. I'm not sure what could be happening.

Re: your second message - in getcensus DP05, years(2020) geography(tract) statefips(1) sample(5) noerror clear, the issue is statefips(1). The Census API expects leading zeros to be present in all FIPS codes and GEOIDs. So the call will work with statefips(01) but not statefips(1).

I expect other users have/will also encounter this issue, so in the next getcensus release, I'll either add an error message if leading zeros are not present, or have getcensus fill in the leading zeros if needed.

-CZ

c-zippel commented 1 year ago

See #60