Search API Connector Documentation
Import Twitter Data to Google Sheets
In this guide, we’ll pull Twitter data into Sheets using the API Connector add-on for Sheets.
In this article, we will only be pulling public Twitter data like tweets, not advertising or analytics data that you have to be logged in to view or manage.
- Before You Begin
- Part 1: Get a Twitter Access Token
- Part 2: Fetch Data from Twitter
- Part 3: Create a Custom API Request
- Part 4: API Documentation
Before You Begin
Click here to install the API Connector add-on from the Google Marketplace.
Part 1: Get a Twitter Access Token
- Navigate to https://developer.twitter.com/ and click Sign up
- You’ll be asked to provide some basic info about yourself. Click Next.
- Read and accept the developer agreement
- You’ll be asked to verify your email address. Click the verification email to finalize your developer account.
- You should be taken to this screen automatically from the verification email, but if not, go to https://developer.twitter.com/en/portal/register/welcome.
- You’ll be asked to create and name an app. Give your app a unique name and click Get keys.
- You’ll now be directed into a screen containing your API keys. Copy down the value listed under Bearer Token. Congrats, you have your Twitter credentials!
Part 2: Fetch Data from Twitter
The easiest way to get started with the Twitter API is through API Connector’s built-in integration.
- Select Twitter from the drop-down list of applications
- Under Authorization, enter the bearer token from above with the word
- Select an endpoint. We’ll start with the
/users/byendpoint, which returns information about a Twitter user
- Fill out the
usernamesparameter with the Twitter users you’d like to look up. Optionally use the
user.fieldsparameter to fetch additional data points.
- Set a destination sheet, name your request, and click Run to see response data in your sheet.
- Pay attention to the value in the
data.idfield. That contains the ID for each Twitter user, which you can plug into other requests.
Part 3: Create a Custom API Request
Alternatively, you can run your own custom requests instead of using API Connector’s pre-built integration. When you create a custom request, you add your complete URL into the request URL field and add a header of Key =
Authorization, Value =
Bearer your token
Part 4: API Documentation
Official API documentation: https://developer.twitter.com/en/docs/api-reference-index
Interactive request generator: https://developer.twitter.com/apitools/api