Using Postman to Fetch Twitter API Data

Cierra Beck
3 min readFeb 15, 2022

--

*Before working with the Twitter API, you need to apply for a Twitter Developer Account, create a name for your app, and store a set of access keys. I’ve gone through a full walkthrough of this process here*

If you’re looking to pull data from Twitter, Postman is the fastest way to do so, with the least amount of set up work required. Postman is made for API development and provides a suite of features for building and testing APIs. For our purpose of pulling data from Twitter, we will be using their API Client, which allows you to quickly send REST requests to an API endpoint. You can access this feature on their web application here, or you can download their desktop application.

In order for us to call the Twitter API, we first need to add the Twitter API Collection to Postman. To do this, navigate to the Twitter API collection page here and click Run in Postman in the upper right. You should see a new collection pop up in Postman!

Now we can start forming our request. Navigate to the Collections tab and find the Twitter API v2 that we just imported. I will be walking you through the Search Tweets function — so navigate to that folder and select GET Recent search. A new tab should pop up with the standard query, looking like below:

Blank Recent Search GET request

Now, we need to authenticate our request so the API knows who is requesting the data. To do this, navigate to the Auth tab within our new GET request and select Type Bearer Token. and enter your personal bearer token from your Twitter Dev account.

Entering Auth Information

Next, we can start entering our search parameters by navigating back to the Params tab. Let’s try to pull recent tweets that use #postman, so in my query param field, I’m going to write ‘#postman’ as the value. A hashtag search is one of the simplest queries to write! Let’s run this basic query and see what we get.

#Postman Search Results

Cool! But this only gives us the Tweet ID and the Tweet text. While this is useful, we can expand on this to get a bit more information. Under params, locate expansions and click the check box to add this field to our search query. Now, we can enter ‘author_id’ in this expansion box to get a little more information on the person writing each tweet. This will give us the author’s ID, name, and Twitter username associated with each tweet. Nice! As our last step, let’s try to fetch the author’s bio description as well. Locate the user_fields parameter and click the check box, then add ‘description’ in the box. Our result now will add the user’s description to the username, id, and name!

Congratulations, you now have a great starting place to explore what additional data you can get from Twitter! You can find the full list of possible query operators here to see all of the different possible types of queries.

Happy coding :)

--

--