How to connect the Census API to Google Sheets

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:

  1. Install the Apipheny add-on
  2. Obtain an API key
  3. Choose a Census endpoint
  4. Enter your Census API request into Apipheny
  5. Run the Census API request in your Google Sheet

Step 1.) Install and open the Apipheny add-on for Google Sheets

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.

open apipheny

Tip: you can open a new Google Sheet by entering this URL in your browser: sheet.new

Step 2.) Obtain an API key

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:

Request a key button
Request a key button

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: 

Request a key page
Request a key page

A confirmation message will be displayed and you’ll receive the API key in your Inbox:

Confirmation message
Confirmation message

After a couple of days, we received the API key. Click the link from your email to activate your key:

API key email
API key email

After you receive the confirmation message, you can use your key:

Activating the API key
Activating the API key

Step 3.) Choose a Census API Endpoint URL

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:

Census API documentation page
Census API documentation page

An example is Decennial Census API. If we expand it, a list of categories for its endpoints will be displayed:

Decennial Census section
Decennial Census section

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:

Decennial Census endpoints
Decennial Census endpoints

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:

Decennial Census endpoint description
Decennial Census endpoint description

Step 4.) Enter your Census API request into Apipheny

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.

Census API request entered in the Apipheny add-on
Census API request entered in the Apipheny add-on

Step 5.) Run the Census API Request in Your Google Sheet

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!

Census data imported into Google Sheets using the Apipheny add-on
Census data imported into Google Sheets using the Apipheny add-on

Crypto API Tutorials:


API Tutorials


API Knowledge

What is an API?

What is an API URL?

What are parameters?

What is an endpoint?

What is an API key/token?

What is basic authentication?

What are headers?

What is a GET request?

What is a POST request?