Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/richecr/pytwittersdk

A Python SDK for the API Twitter.
https://github.com/richecr/pytwittersdk

api hacktoberfest python3 twitter-api

Last synced: about 4 hours ago
JSON representation

A Python SDK for the API Twitter.

Awesome Lists containing this project

README

        

# PyTwitterSDK

A Python SDK for the [API Twitter](https://developer.twitter.com/en).

The [Twitter API](https://developer.twitter.com/en/docs) 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](https://python-poetry.org/docs/).
E então executar o seguinte comando(na raiz do projeto):

```bash
$ 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.

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

### Functions:

- [Post a tweet](#post-to-tweet).
- [Search for tweets](#search-for-tweets).
- [Search for a specific tweet]().
- [Search for tweets from a specific location]().
- [Filter tweets]().
- [Retweet a tweet]().

### Post to tweet:

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

mensagem = twitter.post_tweet("Hello twitter")
```

### Search for tweets:

```python
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

```python
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

```python
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](https://github.com/Rickecr/BibliotecaTwitter/blob/master/CONTRIBUTING.md)