Skip to content

Instantly share code, notes, and snippets.

@quantra-go-algo
Last active September 6, 2022 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quantra-go-algo/2124445a9f482c32f4795f007b2c8265 to your computer and use it in GitHub Desktop.
Save quantra-go-algo/2124445a9f482c32f4795f007b2c8265 to your computer and use it in GitHub Desktop.
# Shall we check out this user's tweets?
name = 'elonmusk'
# Fetch user data
user=client.get_user(username=name).data
# Extract the user id and user name
user_id = user.id
user_name = user.name
# Fetch tweets by the user
tweets = client.get_users_tweets(id=user_id, tweet_fields=['id', 'text', 'created_at', 'context_annotations'])
print(f"Here are the recent tweets by {user_name}:\n")
for tweet in tweets.data:
print(tweet.created_at,'\n', tweet,"\n", tweet.context_annotations,"\n\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment