Skip to content

richecr/PyTwitterSDK

Repository files navigation

PyTwitterSDK

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.

Install:

The library is not yet to be downloaded via pip(yet) or another python package manager. But it can be used as follows:

Import the library:

  • 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.

Credentials:

  • Fill consumer_Key, consumer_Secret, token_key and token_secret of twitter.
from PyTwitter import PyTwitter
twitter = PyTwitter(consumer_key, consumer_secret, token_key, token_secret)

Functions:

Post to tweet:

from PyTwitter import PyTwitter
twitter = PyTwitter(consumer_key, consumer_secret, token_key, token_secret)

mensagem = twitter.post_tweet("Hello twitter")

Search for tweets:

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])

Search for a specific tweet

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)

Search for tweets from a specific location

TODO

Filter tweets

TODO

Retweet a tweet

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)

Contributing:

To contribute is very simple, just follow the steps of CONTRIBUTING.md

Releases

No releases published

Packages

No packages published

Languages