A Python SDK for the API Twitter.
The Twitter API has several features. You can take a look and suggest implementing some functionality in the library. It can be either a feature of the twitter API or even a feature that you think is important, one that you've used a lot and want an easier way to use.
The library is not yet to be downloaded via pip
(yet) or another python package manager. But it can be used as follows:
-
Clone the project:
git clone https://github.com/Rickecr/PyTwitter
. -
Install library dependencies: Para isso vai ser preciso instalar o poetry. E então executar o seguinte comando(na raiz do projeto):
$ poetry install
Ou você pode instalar cada dependência manualmente, se encontra no arquivo
pyproject.toml
. -
Move the
PyTwitter.py
file to where your project. -
Import the file
from PyTwitter import PyTwitter
. -
Okay, now just use it.
- Fill
consumer_Key
,consumer_Secret
,token_key
andtoken_secret
of twitter.
from PyTwitter import PyTwitter
twitter = PyTwitter(consumer_key, consumer_secret, token_key, token_secret)
- Post a tweet.
- Search for tweets.
- Search for a specific tweet.
- Search for tweets from a specific location.
- Filter tweets.
- Retweet a tweet.
from PyTwitter import PyTwitter
twitter = PyTwitter(consumer_key, consumer_secret, token_key, token_secret)
mensagem = twitter.post_tweet("Hello twitter")
from py_twitter import PyTwitter
twitter = PyTwitter(consumer_key, consumer_secret, token_key, token_secret)
# Search for tweets
tweets = twitter.search(query="real madrid", lang="pt-br", tweet_mode="extended")
# Print all tweets
print(tweets)
# Print the first Tweet
print(tweets[0])
Get some specific tweet link like https://twitter.com/caiqueocoelho/status/1261812973774962690
,
the number at the end of the url is the tweet id, get this id and use it in the show function
from py_twitter import PyTwitter
twitter = PyTwitter(consumer_key, consumer_secret, token_key, token_secret)
# Search for specific tweet
tweets = twitter.show(id_tweet=1261812973774962690, tweet_mode='extended')
# Print the tweet
print(tweets)
TODO
TODO
Get some specific tweet link like https://twitter.com/caiqueocoelho/status/1261812973774962690
,
the number at the end of the url is the tweet id, get this id and use it in the show function
from py_twitter import PyTwitter
twitter = PyTwitter(consumer_key, consumer_secret, token_key, token_secret)
# Search for specific tweet
response = twitter.retweet(id_tweet=1320040821631176707)
# Print repose to see if retweet was with success
print(response)
To contribute is very simple, just follow the steps of CONTRIBUTING.md