Using Postman with Twitter API
Tags: twitter, postman, api
Published: 2020-12-26 13:14:43

#introduction
This is my 3rd article on Twitter API series, so some information may need visiting my previous articles.

Let's start...
We don't need to write code to test a Twitter API endpoint. This can be done using Postman.
According to their website: "Postman is used to Quickly and easily send REST, SOAP, and GraphQL requests".

#Getting into Action
You must have a Twitter developer account, to continue with this tutorial.
Now, you'll download postman from [here](https://www.postman.com/downloads/)

![Postman Download Page](https://dev-to-uploads.s3.amazonaws.com/i/rwj9e1zb5wln01qbuuig.png)

You may need to sign up to be able to use Postman. After that you can open it.

![Postman](https://dev-to-uploads.s3.amazonaws.com/i/jaa4ploet2i0mbh3jhdl.png)

There will be some configurations before dealing with Twitter API. First, you'll add an environment by clicking on the button in the following image.

![Environment Button](https://dev-to-uploads.s3.amazonaws.com/i/yuufm5smzppput8fbzez.png)

A new window will appear as you can see in the following image, then click `Add`.

![Manage Environments Window](https://dev-to-uploads.s3.amazonaws.com/i/nzj7wqtnkioj06qik2d3.png)

You can set your environment the same as the following image, you are free to choose the environment name. Use your Twitter account API key, API key secret, access token, and access token secret to filling the `Initial Value` and `Current Value` of the fields, then click `Add`.

![Environment Configurations](https://dev-to-uploads.s3.amazonaws.com/i/ky2rs3atihj40xyk8ky7.png)

Now you have an environment that you can use by selecting it from the environment's dropdown list.

![Environment's Dropdown List](https://dev-to-uploads.s3.amazonaws.com/i/t5lp3svttkljii98fint.png)

Then, you need to open a new request by clicking the `+` button or by clicking `Create a request` from the Launchpad of Postman.

![Create a Request](https://dev-to-uploads.s3.amazonaws.com/i/rk1lpzhjc2uru9mqzrjn.png)

You can use the following endpoint to get tweets of a specific account, see the documentation [here](https://developer.twitter.com/en/docs/twitter-api/v1/tweets/search/api-reference/get-search-tweets)
`
https://api.twitter.com/1.1/search/tweets.json
`

Add this endpoint to the textbox after the word GET as you can see in the following image:

![Request Endpoint](https://dev-to-uploads.s3.amazonaws.com/i/huby3q50sk3s2yg7nlgi.png)

After that, click on the `Authorization` button. In the Type dropdown, select `OAuth 1.0`. The OAuth parameters will appear on the right and will be filled with the environment variables.

![Authorization Types](https://dev-to-uploads.s3.amazonaws.com/i/jacm3lmfw586t7xajwsf.png)

One last step, according to Twitter documentation, this endpoint requires a `q` parameter which is a query text used to search tweets. To add this parameter, click on the `Params` button and add the parameter key and value as in the following image and make sure the checkbox beside the parameter key is checked ☑.

![Request Params](https://dev-to-uploads.s3.amazonaws.com/i/jsm3hoe4zfp8na6v77zn.png)

This will change the endpoint to look like that
`
https://api.twitter.com/1.1/search/tweets.json?q=ahmed_mahallawy
`

Finally, You can click the blue `Send` button, and see the results. If you get a 200 OK status as the following image, this means you did it successfully 🎉

![Successfull Request](https://dev-to-uploads.s3.amazonaws.com/i/eyec10nnuz47lreth3na.png)

That's all. 💪

#Conclusion
Using Postman can be very useful to test Twitter API for your use cases before building your applications. That's why it's very important to understand how to use it.

If you like my tutorials, support me here [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/F2F41UH5T) and follow me on Twitter [![Twitter URL](https://img.shields.io/twitter/url/https/twitter.com/ahmed_mahallawy.svg?style=social&label=Follow%20%40ahmed_mahallawy)](https://twitter.com/ahmed_mahallawy)