Search API Connector Documentation
Import Twitter Data to Google Sheets
New: Updated for Twitter’s V2 API.
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: Create a Twitter Developer Account
- Part 2: Create a Twitter App
- Part 3: Create a Twitter Request URL
- Part 4: Pull Twitter API Data into Sheets
- Part 5: Get More Twitter Data
- Part 6: API Documentation
Before You Begin
Click here to install the API Connector add-on from the Google Marketplace.
Part 1: Create a Twitter Developer Account
- 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.
Part 2: Create a Twitter App
- Once your developer account is approved, you’ll enter the app creation process. You should be taken to this screen automatically from the verification email, but if not, it’s located at https://developer.twitter.com/en/portal/register/welcome.
- Give your app a unique name and click Get keys.
- You’ll now be directed into a screen containing your API keys. Copy down your bearer token as we’ll use that next. Congrats, you have your Twitter app and credentials!
Part 3: Create a Twitter API Request URL
We’ll first look up the user IDs and metadata for some Twitter accounts. You can substitute in any usernames you like.
- API root: https://api.twitter.com
- Endpoint: /2/users/by
- Query Strings: ?usernames=jack,twitterdev,twitterapi,adsapi&user.fields=created_at&tweet.fields=author_id,created_at
Putting it together, we get the full API Request URL:
Part 4: Pull Twitter API Data into Sheets
Now let’s copy that request URL into API Connector.
- Back in the Create Request interface, enter the Request URL we just created.
- We don’t need OAuth, so just leave that set to None.
- Under Headers, enter Key = Authorization, Value = Bearer your_bearer_token.
- Create a new tab and click Set current to use that tab as your data destination.
- Name your request and click Run. A moment later you’ll see information about your users in your Google Sheet.
Part 5: More Example Request URLs
You can check the documentation for the full list of available API requests, but if you just want to jump in, you can play around with the URLs you enter in the API URL path field.
- Get tweets from a specific user ID (6253282 in this example)
- Search tweets for a keyword
- Get public metrics (retweets, replies, likes) for a specific tweet ID
Part 6: API Documentation
Official API documentation: https://developer.twitter.com/en/docs/api-reference-index
Interactive request generator: https://developer.twitter.com/apitools/api