The census provides statistical data regarding the population and housing and their geographical location. We can use the census API to import data from the census into Google Sheets. In this tutorial, we’ll show you how to connect the census REST API to Google Sheets in 5 steps:
Apipheny is an API connector for Google Sheets. You can use Apipheny to connect your Google Sheets to unlimited API data sources, make unlimited API requests, and more. There is a 30 day free trial included.
1.) Install Apipheny by opening the following link on desktop and then clicking the Install button in the Google Marketplace: https://apipheny.io/install
2.) After you’ve installed Apipheny, open a Google Sheet and then click on the Extensions dropdown in the menu at the top.
In the dropdown list you should see Apipheny. Click Apipheny then click Import API to open the Apipheny sidebar in your Google Sheet.
Tip: you can open a new Google Sheet by entering this URL in your browser: sheet.new
Go to https://www.census.gov/data/developers/about.html and scroll down until, on the left side, you find the Request a KEY button, then click it:
On the Request a Key page, complete the organization name and the email fields. Check Terms of service checkbox, then click the Submit Key Request button:
A confirmation message will be displayed and you’ll receive the API key in your Inbox:
After a couple of days, we received the API key. Click the link from your email to activate your key:
After you receive the confirmation message, you can use your key:
In this section, we’ll show you how to browse the Census API documentation to find an endpoint that retrieves the information you need. If you already know your API URL, or you want to use the same example URL as us, just skip to Step 4.
First, open the Census API documentation page: https://www.census.gov/data/developers/data-sets.html
The main section of the page contains a list of available APIs for Census:
An example is Decennial Census API. If we expand it, a list of categories for its endpoints will be displayed:
If we click the Decennial Census (2020, 2010, 2000) category, a list of available API datasets for Decennial Census will be displayed.
An example endpoint is Redistricting Data (PL 94-171).
Each endpoint’s documentation contains the base URL for this dataset, an example request, API variables and Examples and Supported Geography:
Click the 2020 PL Examples and Supported Geography link to find the API base URL, a link to the documentation and other details about this endpoint:
Now, to get your Census data in your Google Sheet, go back to your Google Sheet and make sure that you’ve installed the Apipheny add-on and you have it opened on the Import tab. In the Import tab of Apipheny, enter the following details into the add-on:
Method: At the top of the Apipheny sidebar, select the HTTP method (GET, POST, PUT, PATCH or DELETE) required by your Census API endpoint. For this example, we are using the “POST” method.
API URL: In Step 3, we explained how you can find the Census API endpoint that you need. Now copy your complete Census API URL into the Apipheny add-on, in the field that says API URL Path, followed by any POST parameters required for your query (if applicable).
For this example, we are using the American Community Survey 1-Year Data (2005-2021) endpoint that covers a broad range of topic about social, economic, demographic and housing characteristics of the U.S. population. The URL for this specific endpoint is:
https://api.census.gov/data/2019/acs/acs1?key=API_KEY&get=NAME,B02015_009E,B02015_009M&for=state:*
If you’re following the same example as us, just copy and paste the above URL into Apipheny, but don’t forget to replace API_KEY with your own API key.
The last step is to click the Run button at the bottom of the Apipheny add-on and then your Census data will be imported into your Google Sheets. Congratulations!
Crypto API Tutorials: