Tutorials

Getting started with Postman

Relevant products

Introduction

Postman is a REST client that allows us to make requests to APIs inside of a user interface. This can be helpful when you are working with a new endpoint. To get started with Postman, you first need to apply for a Twitter Developer account. After your account gets approved, you’ll need to create an app

For this example, you’ll be using the Tweets and Users preview for Twitter Developer Labs. You’ll need to first enroll in Labs and attach the app you created to this preview. You’ll also need to create a bearer token using the credentials you just created.

Working with Postman

First, you’ll need to download Postman. You can download the Postman collection for Labs to help you get up and running a bit faster. Once you have your collection downloaded, you can modify the Tweets and Users example which is in a folder called Tweets and Users v1.

Select the example called GET Users.

Now you can edit the request to get the user information from the handle @TwitterDev. You’ll need to replace the URL your’re requesting to https://api.twitter.com/labs/1/users?usernames=TwitterDev&format=detailed

Note, you’ve added the format query parameter with a value of detailed to get all information about the user in the response.

This should look like this:

Before you can press the blue send button you’ll need to adjust your authentication settings. If you click on the tab that says Authorization. Under type you’ll need to select Bearer Token. You can add the bearer token you’ve created into the box next to the word Token.

After you’ve added in your bearer token we submit your request by pressing the blue button that says send.

Now you should see something that looks like the following payload:

 

    {
   "data": [
       {
           "id": "2244994945",
           "created_at": "2013-12-14T04:35:55.000Z",
           "name": "Twitter Dev",
           "username": "TwitterDev",
           "protected": false,
           "location": "Internet",
           "url": "https://t.co/FGl7VOULyL",
           "description": "Your official source for Twitter Platform news, updates & events. Need technical help? Visit https://t.co/mGHnxZU8c1 ⌨️ #TapIntoTwitter",
           "verified": true,
           "entities": {
               "url": {
                   "urls": [
                       {
                           "start": 0,
                           "end": 23,
                           "url": "https://t.co/FGl7VOULyL",
                           "expanded_url": "https://developer.twitter.com/",
                           "display_url": "developer.twitter.com"
                       }
                   ]
               },
               "description": {
                   "urls": [
                       {
                           "start": 93,
                           "end": 116,
                           "url": "https://t.co/mGHnxZU8c1",
                           "expanded_url": "https://twittercommunity.com/",
                           "display_url": "twittercommunity.com"
                       }
                   ],
                   "hashtags": [
                       {
                           "start": 120,
                           "end": 135,
                           "tag": "TapIntoTwitter"
                       }
                   ]
               }
           },
           "profile_image_url": "https://pbs.twimg.com/profile_images/880136122604507136/xHrnqf1T_normal.jpg",
           "stats": {
               "followers_count": 504306,
               "following_count": 1468,
               "tweet_count": 3439,
               "listed_count": 1567
           },
           "most_recent_tweet_id": "1175170649968349184",
           "pinned_tweet_id": "1174361480734466048",
           "format": "detailed"
       }
   ]
}

  

Making your next request

You’ve now made your first request. Congratulations! 

To make your next request, you’ll use GET Tweets to learn more about the most recent Tweet from TwitterDev. To set up, you’ll need to click on the sample request entitled GET Tweets from the folder you were using before.

You’ll first need to modify the URL as you did earlier. In your last example, you saw that the most recent Tweet ID was 1175170649968349184 by looking at the key value pair from your JSON "most_recent_tweet_id": "1175170649968349184". You’ll need to adjust your url to include this most recent Tweet: https://api.twitter.com/labs/1/tweets?ids=1175170649968349184.

This should look like this in Postman:

You’ll also need to update authentication settings, as you did in the previous request, using the same bearer token you created earlier in this process.

After you’ve made your changes you’re ready to press the blue send button. After you do so, you should see the following payload:

 

    {
   "data": [
       {
           "id": "1175170649968349184",
           "created_at": "2019-09-20T22:11:31.000Z",
           "text": "Check out this summary of our recent #TapIntoTwitterLA + @NASAJPL MeetUp workshop! 🚀🤖👇https://t.co/457khkpJgF",
           "author_id": "2244994945",
           "entities": {
               "urls": [
                   {
                       "start": 86,
                       "end": 109,
                       "url": "https://t.co/457khkpJgF",
                       "expanded_url": "https://blog.twitter.com/developer/en_us/topics/community/2019/tapintotwitter-nasa-recap-blog.html",
                       "display_url": "blog.twitter.com/developer/en_u…"
                   }
               ],
               "hashtags": [
                   {
                       "start": 37,
                       "end": 54,
                       "tag": "TapIntoTwitterLA"
                   }
               ],
               "mentions": [
                   {
                       "start": 57,
                       "end": 65,
                       "username": "NASAJPL"
                   }
               ]
           },
           "format": "default"
       }
   ]
}

  

What's next

If you click on the button in Postman that says code, you can turn the request we just created into the language of your choosing such as Python, Node or Ruby to help you get started. Postman has great documentation that might be helpful. You can also check our sample code on GitHub. Be sure to also check out our documentation on Labs to learn more.

Ready to build your solution?

Apply for developer access to get started