Twitter API Guide
Twitter has an interesting API which contains multiple options for developers to research. Here we review several topics of how to work with Twitter API v2 using API tester app:
- Actions with likes,
- Retweets information,
- Timeline’s use.
To be able to send requests to this API you will need to get an access token. To get that you should create a developer’s account on Twitter. The full instruction you can get via this link:
https://developer.twitter.com/en/docs/twitter-api/getting-started/getting-access-to-the-twitter-api
To get a developer’s account your personal Twitter account must be fully verified. This includes your current email address and a phone number. Without this information you will not be able to get an access to the Twitter API.
As far as Twitter has a very strict developer’s policy make sure that information that you filled in your application do not violates this policy! Sometimes it takes time before your application to the developer’s account will be approved by moderators.
Once you got all necessary access keys you can proceed to Twitter API.
All requests have the common endpoint:
https://api.twitter.com
The methods of twitter API accepts various parameters which are used to cusotmize the requests according to needs. The list of Twitter API v2 endpoints with detailed request description can be found via this link:
https://developer.twitter.com/en/docs/api-reference-index#twitter-api-v2
With Twitter API v2 you can get an access to the information about user’s likes. Let’s try to make a GET request to review a list of liked Tweets by a concrete user. For example, we’ll take an official account of Elon Musk. To get started with request we need:
- 1.To tap «Create new request» button and select GET method.
- 2.To place this endpoint into the address line:https://api.twitter.com/2/users/:id/liked_tweets

You can import this request into API Tester app via these links:
- curl -X GET 'https://api.twitter.com/2/users/:id/liked_tweets'
Note that you need to place your Bearer Token into the OAuth section of EACH REQUEST in order to get a response!

Now we will need to add a user ID. To find a user ID you need to make an additional request to retrieve a singe user with a username:
You can import this request into API Tester app via these links:
- curl -X GET ‘https://api.twitter.com/2/users/by/username/:username'
After importing this request you need to place a username into the Path Variables section. In this example we’ll take Elon Mask account, it’s username «elonmusk».
When all parameters are set we can run request. In the response we can find a user’s ID, name and username.

Now we can copy the ID and get back to the initial request. Place the user ID from previous step into the Path Variables section and run the request.
Done! Now you can find a list of 100 tweets liked by the user.

There are some additional parameters available for this request. You can find their description and purpose here:
https://developer.twitter.com/en/docs/twitter-api/tweets/likes/api-reference/get-users-id-liked_tweets
Let’s add parameters "expansions" (to get a users IDs) and "max_results" (to get 10 Tweets instead of 100). To do that you need to place a meaning "author_id" for parameter «expansions» and number 10 for parameter "max_results".

This response contains not only Tweets information but also at the end you can find all user IDs mentioned in the response with their usernames.
Now we will review the request which allows you to get the information about Tweet’s liking users. The endpoint is following:
https://api.twitter.com/2/tweets/:id/liking_users
You can import this request into API Tester app via these links:
- curl -X GET ‘https://api.twitter.com/2/tweets/:id/liking_users'