The Census Bureau started releasing APIs. Anyone who knows a small amount of R or Python can access it. You might shrug this off at first, but I’d seriously consider the opportunity this brings.
Whether you're doing market research, opening a business in a new city, or placing targeted ad buys, this data is super helpful.
The Census Does More Than Basic Population Counts
If you’re aware of the Census Bureau and what it does, then you’re probably aware of the nationwide survey that’s done every 10 years, which is known as the decennial census. This is more or less a basic population count with standard demographic data.
But did you know the Census Bureau collects even more data beyond that?
The Census Bureau collects data on individual incomes, education levels, internet usage, access to basic appliances, homeownership, employment, etc.
If you’re considering building a new store that sells products geared towards men aged 25 through 34 who earn more than $100k a year, wouldn’t it be good to know what neighborhoods have the highest concentrations of that demographic?
This is possible with the Census Bureau data.
What Are the Currently Available API Connections?
Census conducts various surveys that focus on different topics. They compile the responses into several databases, which you can access through an API connection.
When I wrote this article, there were 23 API connections available. Some of these APIs come from the same surveys, but are broken down in different ways, such as year or sub-topic.
The two APIs I think are the most useful are:
American Community Survey
# 1: Decennial Census
This is the database that most people think of when they think of “The Census.” This survey is widespread and involves collecting data on every household possible. It’s a huge undertaking and it’s done only every 10 years.
While it’s impossible to count every single person living in the United States, the Decennial Census attempts to do as good of a job as possible. (Fun fact: this process is mandated in the U.S. constitution)
Decennial Census data includes demographic information, such as age, sex, race, and household type.
Because it has a larger sample than any other survey, I would use this for research if it has the demographic data you want and the current date is within 2-3 years of the last Census conducted.
So if it's the year 2022 and you want a simple population count of your hometown, this is a good survey to use.
# 2: American Community Survey
Even though the Decennial Census is what most people think of when they think of “The Census,” the American Community Survey is a far more comprehensive survey.
The American Community Survey is distinct from the Decennial Census in a number of ways.
The first is that it doesn’t attempt to capture the total US population. Instead, it takes a sample of the US population, with the belief that a large enough sample will accurately reflect the overall population. (Fun fact: I’ve been interviewed in person by a Census Bureau employee for this survey)
The second is the frequency the Census Bureau conducts this survey. The American Community Survey is conducted yearly for areas with a population greater than 65,000 and every five years for populations below that amount. (The Census Bureau had conducted a three year survey for areas with a population between 20,000 and 65,000, but that was discontinued.)
The third is the level of detail. Because the Census Bureau uses sampling, they’re able to collect far more detailed data that would be difficult with a full-blown census. American Community Survey has more groupings and variables than the Decennial Census. This makes the American Community Survey (in my opinion) a far more useful data source.
The American Community Survey has data regarding social, economic, and demographic information. For example, you can discern how many Hispanic Americans between the ages of 25 to 34 have a college degree in a given zip code. You can determine income by race. You can also determine homeownership rates for millennials.
Unavailable API to Look Out For: Current Population Survey
The Current Population Survey measures the economic well-being of American citizens and is conducted monthly. This survey is actually a joint effort between the Census Bureau and the Bureau of Labor & Statistics.
The Current Population Survey is not available in its entirety as an API. Currently, the Census Bureau only makes health insurance statistics from this survey available as an API.
The Current Population Survey is similar to the American Community Survey, but includes more comprehensive data about income and the demographics of those at various income levels.
With the American Community Survey, you can look at income by race, education by race, education by sex, education by age, etc. but you can’t look at income by race by age by education by sex.
That might not sound like a huge distinction, but it does bring limitations if you want to move from demographic research to analysis.
I’m not sure when they’ll be releasing this API, but I look forward to the day they do.
How Do You Connect to the APIs?
You can connect and extract this data using Python or R.
One thing you will need is an API key. You can sign up for that here.
I will write a longer tutorial on how to extract this data using R in the near future, but if you’re already familiar with R, you can download this short script and get started on your own.
I don’t know Python, so I won't attempt to write a script. It would probably look barbaric to more seasoned Python pros. Instead, you can visit this page for instructions.