Quickstart¶
This page is a simple and brief quickstart to pytweet!
A Basic PyTweet Client¶
import pytweet
client = pytweet.Client(
"Your Bearer Token Here!!!",
consumer_key="Your consumer_key here",
consumer_key_secret="Your consumer_key_secret here",
access_token="Your access_token here",
access_token_secret="Your access_token_secret here",
)
#if you dont have one make an application in https://apps.twitter.com
user = client.get_user_by_username("TheGenocides")
print(user.name, user.username, user.id)
# Return The user's name, username, and id
tweet = client.get_tweet(Tweet ID Here)
print(tweet.text, tweet.id, tweet.author.username)
# Return the tweet's text, id, and the author's username.
Name this file pytweet_example.py
Steps to running it¶
Install pytweet, with
pip install pytweet
Run
python3 pytweet_example.py
to run it.
Steps in our code¶
We are importing pytweet using
pytweet
We are making our Client instance using
client = pytweet.Client(...)
We are fetching a user using
client.get_user_by_username
We are printing out the user name and ID
We are fetching a tweet using
client.get_tweet
We are printing out the tweet’s text, tweet’s id and the tweet’s author’s name