There’s a lot of different ways to export data from Twitter to Google Sheets. The best way is to use the Twitter API.
To pull data from Twitter into Google Sheets, you’ll have to install and open the Apipheny Google Sheets add-on.
Apipheny is a no-code API integration and data analysis tool for Google Sheets. You can use Apipheny to make unlimited API requests, connect to unlimited APIs, save API requests, schedule API requests, and more. Click here for more information about Apipheny. There’s a 30-day free trial included, then it’s $19-$29/month.
1. To Install Apipheny, start by opening the following link on desktop and then clicking the Install button on the page: https://gsuite.google.com/marketplace/app/apipheny/966163326746
2. After you’ve installed Apipheny, open a Google Sheet and in the navigation menu at the top of your Google Sheets, click on the Add-Ons option. Then, under the add-ons menu, you should see Apipheny if you’ve installed it already.
Click Apipheny > Import API to open the Apipheny sidebar in your Google Sheets then go to the next step.
First, make sure you’re logged in to your Twitter account.
Then, in your Twitter developer account’s dashboard, click on the developer menu item on the top right side of the page. Then, in the drop-down menu, select the Apps item:
Then, on the next page, click the Create an app button:
Complete all the required fields (App name, Website URL and Tell us how this app will be used) and then click the Create button:
Then, in the Review our Developer Terms popup, click the Create button:
Your app has now been created and the app’s details will be shown on the page:
On the app’s Keys and tokens tab, you will find the API key and API secret key necessary to generate a Bearer token:
In your console window, enter the following command and press the Enter key to run the command:
curl -u "<your_API_key>:<your_API_secret_key>" --data "grant_type=client_credentials" "https://api.twitter.com/oauth2/token"
Your Bearer token will then be displayed in the response.
Copy and paste your Bearer token somewhere safe because you will need it in the next steps.
In this section, we’ll show you how to browse the Twitter API documentation to find an API URL endpoint that retrieves the data you need from Twitter, if the data you want is available from the Twitter API. If the data you need is not available via the API, then you’ll need to use another method such as scraping.
You can check if the data you need is available from the Twitter API by checking the API documentation to see what endpoints are available. An endpoint is the last part of the API URL that tells the Twitter API what specific data to return back to you.
If you already know the Twitter API base URL and endpoint that you need, or you want to use the same example URL as us, just skip to Step 4.
To browse the available Twitter endpoints, first open the Twitter API documentation page: https://developer.twitter.com/en/docs/api-reference-index
The menu on the left contains a list of categories for the available APIs:
The full list of categorized APIs and their endpoints are displayed on the right of this menu, squared in purple.
Clicking on an endpoint link opens the dedicated page that shows the endpoint’s details in the context of its API. All the API’s available endpoints are first shown as part of a Table of Contents, with the current endpoint selected.
For example, if you click the endpoint Accounts and users > Create and manage lists > Get lists/list (https://api.twitter.com/1.1/lists/list.json), the dedicated page will first show the API’s name (Create and manage lists), followed by a Table of Contents containing links to all this API’s endpoints:
Lower down the page, the specific documentation contains the HTTP method used (eg. GET) and the endpoint’s URL path (/lists/list.json), a short description of the endpoint’s purpose, a description of the available parameters and an example request and response:
All API calls to Twitter should be made to the https://api.twitter.com/1.1/ base URL, and all endpoints and parameters should be appended to this base URL:
Twitter API Base URL/root domain: https://api.twitter.com/1.1/
In the next step, we show an example API request to Twitter from Google Sheets with a completed API URL.
Now here’s the last step. 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 Twitter REST API endpoint that you need. Now copy the complete URL into the Apipheny add-on, where it says API URL Path (JSON / CSV), followed by any GET parameters required for your query.
For this example, we are using the statuses/user_timeline endpoint, that returns a collection of the most recent Tweets posted by the user indicated by the screen_name or user_id parameters.
The complete API URL with parameters for this endpoint is:
You can copy and paste the above example API URL into Apipheny and try it out. Just replace screen_name with the username/handle of any valid Twitter user.
Headers: In the Headers section of the Apipheny add-on, add one row with the following key and value:
Headers Key: Authorization Value: Bearer your_access_token
If you’re following this example, just copy “Authorization” into the Key field and “Bearer your-access-token” into the Value field.
your_access_token is the value you generated previously, in Step 3. There should be a literal space between “Bearer” and “your_access_token”.
Here’s our Twitter API request entered into Apipheny, with the API URL and headers:
Finally, click the Run button at the bottom of the Apipheny add-on and then wait for the Twitter API data to be imported into your Google Sheet, like this:
After making a successful request to the Twitter API, try querying a different endpoint, or try changing the parameters in the API URL. You could also try using one of the more advanced features in the Apipheny add-on, such as: