Import Twitter data to Google Sheets

How to import Twitter data to Google Sheets
Reading Time: 5 minutes

Steps to import Twitter data to Google Sheets:
Step 1: Install Amigo Data add-on
Step 2: Get the API key and secret, and bearer token
Step 3: Choose the endpoint
Step 4: Import the data

Twitter lets developers pull several types of data from its platform such as users information like followers list, following list, tweets timeline, tweet information; trending topics–globally, or by countries and regions; and also information that are not publicly available such as tweets impressions, and other metrics.

You don’t need to be a developer or have any knowledge of programming, however, to create a Twitter-Google Sheets integration and import Twitter data to Google Sheets as you can easily do them with Amigo Data, a data integration and automation tool–without code and without a hassle.

So, let us learn step by step how to create a Twitter Google Sheets integration and import Twitter data to Google Sheets.

How to import Twitter data to Google Sheets

Trace the steps below to create a Twiter Google Sheets integration and import Twitter data to Google Sheets.

Step 1: Install the Amigo Data add-on

Install the Amigo Data Google Sheets add-on in Google Sheets from the Google Workspace Marketplace to import Twitter data to Google Sheets.

Click here to install

Install Amigo to import Twitter data to Google Sheets

Step 2: Get the Twitter API key and secret, and bearer token

In order to integrate Twitter with Google Sheets and pull data from Twitter to Google Sheets, we need to create an app on Twitter’s developer platform and generate an API key, secret key and bearer token.

Follow the steps given below to create an app and generate a bearer token and other keys.

1. Go to Twitter’s Developer Platform and sign in using your Twitter account (or sign up if you don’t already have one).

Twitter Developer Platform homepage

2. After you’ve signed in (or up), click Developer Portal.

Developer Portal on Twitter's Developer Platform

3. On the next page, you’ll be asked to enter certain details. After filling in those fields and accepting the Developer Agreement and confirming your email, you’ll be redirected to the developer portal with a welcome message.

Welcome page on Twitter Developer Platform

4. Give the app a name and click Get keys. The API key, API key secret, and Bearer token will be generated immediately. Copy those to a safe and confidential location.

The API keys and Bearer Token

If you have got the Twitter API keys and the token, we can proceed to pull data from Twitter to Google Sheets.

Step 3: Choose a data endpoint

All data have an endpoint URL which points to that particular dataset. There are several ways to get the endpoint URL. We’ll use a simple and interactive one.

From the previous page (where the keys were displayed) click the API Playground button. You can also click this link to go to that page or click on Go to API playground from the Developer Portal dashboard.

LIst of projects

On the playground page, search for the data sets you want to import using the search bar.

As an example, let us import Elon Musk’s tweets timeline. So we can simply search “timeline”.

Choosing the endpoint

Select GET /2/users/:id/tweets

There are some parameters to be filled some of which are mandatory.

The user ID can be got from here. Just enter the Twitter handle and it will give the ID of that user.

Twitter ID

Copy the ID and paste it in the id field.

The since_id is the ID of the tweet from which the timeline begins, ie, from that tweet onwards.

The tweet ID can be found by opening the particular tweet. The numbers following status in the tweet URL is the tweet ID.

For example, below is one of Musk’s tweets. The numbers 156…8 is the tweet ID. https://twitter.com/elonmusk/status/1564993132873146368 

Fill in the other parameters and fields if you want (they’re not mandatory) and click Run.

Running the request

Then on the next page, click Authorize app.

Authorizing the app to make the request

You’ll see the response on the screen. 

Expanding the details

Click the three dots just above the top right corner of the response field to see the details of the response.

The endpoint URL can be found under cURL. Copy that without including the quotation marks.

The endpoInt URL

You can also get the endpoints using the Twitter API tools. The process is more or less the same as the one just covered here.

Step 4: Import the data from Twitter to Google Sheets

Now that we’ve got all the materials we need, we can begin to import Twitter data to Google Sheets. Follow the steps below to import the data using Amigo Data.

  • Launch the Amigo Data extension from Google Sheets
Launching Amigo Data in Google Sheets
  • From the list of sources, select Custom API.
Selecting the source
  • Paste the endpoint URL in the API URL bar.
  • Then expand the Details tab and enter the following as a header.
    Name: Authorization, Value: Bearer your_token
  • Click PREVIEW and then flatten the data sets
  • Finally click the IMPORT button

The Twitter data will be imported to Google Sheets in a moment. Below is a snippet of the imported data.

Snippet of the imported data

And so that’s how we import Twitter data to Google Sheets. We don’t even have to log in to Twitter to read tweets as the data will be automatically updated and refreshed.

For more endpoints and details on Twitter API, you can check out Twitter API documentation.

Setting refresh schedule

To get the information updated periodically, click the report, toggle on the Refresh Schedule and select the schedule–hourly, daily, weekly or custom days.

Then click Save & Run.

Alerts via email or Slack

You can get the report sent to your email or a Slack channel so that you do not even have to open the spreadsheet to keep track of what’s happening or being tweeted.

To set up an alert, click Get Alerts→Add alert data+. Edit the details and click Set Alert.

Conclusion

It becomes an easy process to integrate Twitter data to Google Sheets–once the first procedure has been completed. And then we can watch and read tweets from a distance without getting into the mess that Twitter is, or get the trends and other metrics into Google Sheets.

See Also

There are several other types of data that you can import to Google Sheets using Amigo Data. A few examples are stock data from Yahoo Finance, cryptocurrency prices and market capitalisation, US patent information, and Wikipedia.

For these and many more, visit our blog.

Some similar articles you may find interesting:

https://blog.tryamigo.com/import-reddit-data-to-google-sheets/

https://blog.tryamigo.com/import-data-from-nasdaq-to-google-sheets/

https://blog.tryamigo.com/import-bscscan-data-to-google-sheets/

Leave a Reply

Discover more from Amigo: No-code Data Integrations to Google Sheets

Subscribe now to keep reading and get access to the full archive.

Continue reading