've just started working with Census APIs, and so far I'm loving what this can do to improve my work flow when working with American Community Survey Data.
For most of the data work I'm doing, my primary geographic level is the county subdivision. BUT, I also like to include data for each of the counties I'm working with, and the state level.
I know how to access EACH of those three levels, but I'm not sufficiently familiar with JSON programming protocols to know how (or whether) I can combine multiple geographic LEVELS in a single API data call?
I have been looking at the EXAMPLES found here [https://api.census.gov/data/2019/acs/acs5/examples.html], and don't see any that combine multiple geographic levels, but I strongly suspect this is something I should be able to do?
Thanks for any assistance folks can offer.
P.S FYI, this is me here: www.twitter.com/DougHallPhd and here: https://www.linkedin.com/in/douglashallphd/
Interesting! Looks like those links are dead. Can you try this link: https://join.slack.com/t/uscensusbureau/shared_invite/zt-mypta05e-LR87zxmoSNJb~0YABKlafQ
That is an invite link I was able to create…
As far as I know, you can only request a single geography in each API call. But the structure of the calls and the data returned are consistent, so you could write a for loop or use other functions to iterate through each geography you want and create the API calls. You don't mention how you are accessing the API, but if you are an R user, I highly recommend the tidycensus package, which wraps the API in a pretty easy interface and pulls the data directly into.
Here for example is one way to get data for county subdivision, county, and state using R and tidycensus:
geos <- c("state", "county", "county subdivision")
purrr::map_dfr( geos, ~ tidycensus::get_acs( geography = .x, state = "MA", variables = "B01003_001", survey = "acs5", year = 2019 ))
There also is a Cenus Slack channel which is a good place to ask questions about using Census APIs
Thanks, Matt. I'm definitely a newbie with R but will bookmark your reply so I can use this format when I get to that point of the learning curve! (As for the Census Bureau Slack channel, I'm definitely interested, but have to figure out how to navigate the process without a Census Bureau email address). Cheers, Doug.
You should be able to join the Census slack with any email address -- it's for API users and there are some Census staff that answer questions. If that link isn't working, try the link at the top of this page: https://www.census.gov/data/developers.html
Good luck on your R journey! If you haven't already found it, R for Data Science is my favorite resource for learning R: https://r4ds.had.co.nz/
Hi Matt! Do you think you could ping the admin to have them change the settings? I'm trying to join the Slack workspace but it does require a @census.gov email address:
Don’t have an @census.gov email address?Contact the workspace administrator at U.S. Census Bureau for an invitation.
I'm trying these entry points:
That is an invite link I was able to create from Slack.
Either way I’ll let Logan at Census know the link on the developer page isn’t working.
That worked – thank you so much, Matt!
Thanks, btw, Matt. There were some issues getting into the Slack group, but I'm there now. I appreciate all the resources and support I can get! Cheers, Doug.
Hi Matt, I am also trying to join the Slack but none of the links in this thread work. They all require me to have a @census.gov email address. I was wondering if you could send a new invite link so I could join.
Does this work?
I’m not sure why the links keep expiring!