FoodData Central is an integrated data system that provides expanded nutrient profile data and links to related agricultural and experimental research. We can use the FoodData Central API to import data from FoodData Central into Google Sheets. In this tutorial, I’ll show you how to connect the  FoodData Central REST API to Google Sheets in 5 steps:

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

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

Apipheny is a free API connector for Google Sheets. You can use Apipheny to connect your Google Sheets to API data sources, easily.

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://fdc.nal.usda.gov/api-key-signup.html and sign up for an API key.

After completing all the required fields, click the Signup button:

Signup page for FoodData Central
Signup page for FoodData Central

After signing up, you will receive the API key:

FoodData Central API key
FoodData Central API key

You will also receive an email containing the API key. You will need the API key in the next steps.

Step 3.) Choose an endpoint

In this section, we’ll show you how to browse the FoodData Central API documentation to find the endpoint that retrieves the information you need from your account. 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 FoodData Central API documentation page: https://fdc.nal.usda.gov/api-spec/fdc_api.html#/

This page contains a list of endpoints, each one with its description:

FoodData Central API documentation page
FoodData Central API documentation page

An example endpoint is Foods, which fetches details for multiple food items using input FDC IDs. The URL for this endpoint is:

https://api.nal.usda.gov/fdc/v1/foods/FOOD_DATA_ID?api_key=YOUR_API_KEY

If you use this URL, don’t forget to replace FOOD_DATA_ID with a real id and YOUR_API_KEY with your API key.

The endpoint’s documentation contains a short description of the endpoint’s purpose, its HTTP method (GET) and URI, a list of accepted parameters and an example response:

Endpoint documentation
Endpoint documentation

All endpoints can be accessed with the following base domain: https://api.nal.usda.gov/fdc/v1/

Step 4.) Enter your API request into Apipheny

Now go back to your Google Sheet and make sure that the Apipheny add-on is open on the Import tab. With the Import tab open, enter these details into the add-on:

Method: At the top of the Apipheny sidebar, select the HTTP method (GET or POST) required by your API endpoint. For this example, we are using the GET method.

API URL: In Step 3, we explained how you can find the FoodData Central API endpoint that you need. Now copy and paste your complete FoodData Central API URL into the Apipheny add-on, where it says API URL Path, followed by any parameters required for your query (if applicable).

For this example, we are using the List endpoint, which returns a paginated list of foods, in the ‘abridged’ format. This is what the whole URL looks like:

https://api.nal.usda.gov/fdc/v1/foods/list?api_key=YOUR_API_KEY

If you use this URL, don’t forget to replace YOUR_API_KEY with the value of the API key you previously obtained in Step 2.

Headers aren’t required. You can leave the Headers section blank in Apipheny.

Here’s what our API request looks like in Apipheny:

 FoodData Central API request entered into Apipheny
FoodData Central API request entered into Apipheny

Step 5.) Run the FoodData Central API request in your Google Sheet

Finally, the last step is to click the Run button at the bottom of the Apipheny add-on and then wait for the FoodData Central API data to be imported into your Google Sheet. Here’s what our request looked like when completed:

 FoodData Central data imported into Google Sheets
FoodData Central data imported into Google Sheets

That’s it! You’ve successfully connected your FoodData Central account to Google Sheets using the FoodData Central API, Google Sheets API, and the Apipheny add-on.

After making a successful request to the FoodData Central API, try querying a different FoodData Central API endpoint, or try using one of the more advanced features in the Apipheny add-on.


Crypto API Tutorials:


Popular 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?