https://github.com/ap--/tweettr
thin `attrdict` like wrapper around (a few) Twitter JSON objects
https://github.com/ap--/tweettr
Last synced: about 1 month ago
JSON representation
thin `attrdict` like wrapper around (a few) Twitter JSON objects
- Host: GitHub
- URL: https://github.com/ap--/tweettr
- Owner: ap--
- License: mit
- Created: 2020-02-16T15:43:28.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-16T16:02:19.000Z (over 6 years ago)
- Last Synced: 2025-02-21T12:16:42.517Z (over 1 year ago)
- Language: Python
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Tweettr - thin attrdict like wrapper around (a few) Tweet objects
[](https://pypi.org/project/tweettr/)
[](https://pypi.org/project/tweettr/)
[](http://opensource.org/licenses/MIT)
[](https://github.com/ap--/tweettr/issues)
[](https://github.com/sponsors/ap--)
Tweettr gives you a convenient attribute interface to (some) tweet objects without any copying overhead.
And if your editor or IDE understands type annotations it let's you do attribute auto completion.
It also add a way to provide emoji parsing with a similar interface to `.entities.hashtags`. :sparkling_heart:
So when you receive a json object from the twitter streaming api you can access it in a nicer way:
```yaml
# json blob returned from twitter streaming api
{
"id": 11223344556677889900,
"id_str": "11223344556677889900",
"created_at": "Sun Feb 16 13:16:19 +0000 2020",
"user": {
"id": 11223344556677889900,
"id_str": "11223344556677889900",
"screen_name": "AAAAAAAA",
# ...
},
"entities": {
"hashtags": [{
"indices": [12, 21],
"text": "MyHashTag"
}]
},
"text": "Hello World #MyHashTag",
"favorite_count": 0,
"favorited": false,
"timestamp_ms": "1500000000000",
"truncated": false,
# ...
}
```
becomes:
```python
>>> import tweettr
>>> tweet = tweettr.Tweet(json_blob)
>>> tweet.user.id
11223344556677889900
>>> tweet.user.screen_name
'AAAAAAAA'
>>> tweet.emojis # extract emojis like HashTags and Urls...
[Emoji(...), Emoji(...)]
>>> ... # etc, etc...
```