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
You may need to sign up to be able to use Postman. After that you can open it.
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.
A new window will appear as you can see in the following image, then click Add
.
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
.
Now you have an environment that you can use by selecting it from the environment's dropdown list.
Then, you need to open a new request by clicking the +
button or by clicking Create a request
from the Launchpad of Postman.
You can use the following endpoint to get tweets of a specific account, see the documentation here
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:
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.
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 ☑.
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 🎉
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 and follow me on Twitter
Top comments (0)