Integrate Facebook Pages with Google Sheets

The Facebook Pages API allows apps to access and update a Facebook Page’s settings and content, create posts, get post data, get comments data on page owned content, get page insights, update actions that users are able to perform on a page, and much more.

API authentication for the Facebook Page API is handled through Access Tokens. Most endpoints require Page access tokens, which are unique to each Page, app user, and app, and have an expiration time. In order to get a token from an app user, the app user must own or be able to perform a Task on the Page.

In this tutorial, I’ll show you how to connect the Facebook Pages REST API to Google Sheets in 6 steps using the Apipheny Google Sheets add-on:

  1. Install the Apipheny Add-on
  2. Create a Facebook App
  3. Get your Access Token
  4. Get the endpoint URL
  5. Add the URL into the Apipheny Add-on
  6. Run the Facebook Page API Request

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:

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:

Step 2.) Create a Facebook App

1.) Begin by navigating to and click My Apps > Create App:

2.) Fill out your details and click Create App ID. You can call your app anything, but in this example we’ll call it ApiphenyApp:

3.) You’ll then be directed to your Developer dashboard. You don’t need to do anything in this dashboard. Instead, click Tools, then Facebook Graph API Explorer:

4.) Click Get User Access Token from the User Tokens drop-down menu:

5.) Click the Add a Permission field to search for permissions you want to add, or click in the section beneath this field to select them from a list. For this example, make sure you’ve selected at least the pages_manage_ads, pages_manage_metadata, pages_read_engagement, pages_read_user_content and read_insights permissions:

6.) After you’ve selected the permissions, click the Generate Access Token button.

You will be asked to approve your permission through App Review. If you have a role, like admin, developer or tester, then you can click the Done button and move forward, because this action isn’t needed.

App Review - Permissions
App Review – Permissions

You should now see your first access token. However it only lasts for 1 hour. We can extend it by clicking the small blue icon next to this short-lived access token, and then in the pop-up, clicking the Open in Access Token Tool button:

7.) The Access Token Debugger will open at the bottom of the page, then click Extend Access Token:

8.) This will produce a long-lived token. Click Debug to view the whole value and copy it to your clipboard, as we’ll need it in a moment:

Step 3.) Get your permanent Facebook Pages API Access Token

1.) Navigate back to the Facebook Graph API Explorer. Paste the long-lived token you just got into into the “Access Token” field:

2.) Enter {page ID}?fields=access_token into the URL field, making sure to substitute {page ID} with your own Page ID.

👉 To get your Facebook Page ID, open up the Facebook page you want to connect, and click About in the menu on the left. Then scroll down and you will see the Page ID listed.

In this example, the URL is 109868280670999?fields=access_token, as shown in the screenshot below. After adding your URL, click Submit:

3.) After you click Submit, you’ll see your permanent Page Access Token returned in the response. Copy this value (shown in green text below) somewhere safe, so that you won’t have to go through the same process again:

Note: If the token that you generate has an expiration time, you will need to complete this same process again to get a new token when the old one expires.

Step 4.) Get a Facebook Page API URL endpoint

To find descriptions and examples for the different Facebook Pages API endpoints you can use, go to the relevant section of the Graph API documentation here:

On that page, in the menu on the left, in the Reference section, you will find the list of available endpoints. You can also run a search for an endpoint in the Search bar if you can’t easily spot the one you need in the list.

Select any of the endpoints and the corresponding documentation page will be opened. For instance, this is how the Page Feed endpoint looks like:

Facebook API Page Feed Endpoint Documentation
Facebook API Page Feed Endpoint Documentation

If you want to use the same example URL endpoint as us, continue to the next step.

Step 5.) Add your Facebook Pages API URL into the Apipheny add-on

After you get the endpoint that you need, copy the complete URL into the Apipheny add-on, where it says API URL Path, followed by any GET parameters required for your query.

The Facebook API URLs generally have this format:

You will have to replace the placeholders with the latest API version (12.0 currently), your own Page ID, the endpoint’s URL and the Access Token we obtained in the previous step.

Note: Facebook changes the version of their API often. Check their documentation to confirm the latest version and update the version number in the URL if necessary.

At the top of the Apipheny sidebar, select the HTTP method (GET or POST) as required by your API endpoint. In this example we are using GET, as you can see in the screenshot below.

In this example we accessed the latest posts from the Page, using the feed endpoint:

Don’t forget to replace page_id with your own page id and write your own access token.

Insert the API Request URL into the Apipheny API URL Path field like in the image below:

Facebook Pages API request entered into Apipheny
Facebook Pages API request entered into Apipheny

You don’t need to add anything else in the add-on besides the URL.

Step 6.) Run the Facebook Pages API Request in Google Sheets

Click the Run button at the bottom of the Apipheny add-on and then wait for the Facebook Pages data to be fetched and added to your Google Sheet:

Facebook Page API data in Google Sheets

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

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?

Import JSON to Google Sheets

Need website help? Hire an SEO Consultant.