Working With Census API and ACS 5-year data

'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.

Cheers, Doug.

P.S FYI, this is me here: www.twitter.com/DougHallPhd and here: https://www.linkedin.com/in/douglashallphd/ 

Parents
  • 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. 

Reply
  • 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. 

Children