-
Notifications
You must be signed in to change notification settings - Fork 3
Method: Tweet lookup
Matthew R. DeVerna edited this page Aug 1, 2021
·
3 revisions
Tweet lookup endpoint returns information about a group of Tweets specified by their IDs.
Note that Twitter also has an endpoint to fetch a single tweet, but we only implement the one allowing fetching multiple tweets because you can use the below method to pull a single tweet as well
import osometweet
# Initialize the OsomeTweet object
bearer_token = "YOUR_TWITTER_BEARER_TOKEN"
oauth2 = osometweet.OAuth2(bearer_token=bearer_token)
ot = osometweet.OsomeTweet(oauth2)
tweet_ids = ['1323314485705297926', '1328838299419627525']
# Fetch the tweets information
response = ot.tweet_lookup(tweet_ids)
print(response["data"])
The code above should produce something like
[
{'id': '1323314485705297926', 'text': 'breathe'},
{'id': '1328838299419627525', 'text': 'some of you hating...\n\nbut we see you Fleeting 🧐'}
]
V2 API, by default, only returns limited information.
To fetch more, you will need to specify the fields
and expansions
parameters in the requests.
OSoMeTweet
contains several classes to handle them.
See Method: Specifying fields and expansions for examples of how to work with them.