Twitter API
Project description
The Undocumented Twitter API
A free alternative to the Twitter API
Automation
from twitter.main import *
from twitter.login import login
usr, pwd = ..., ...
session = login(usr, pwd)
# DM 1 user
dm('hello world', [123], session, filename='test.png')
# DM group of users
dm('foo bar', [123, 456, 789], session, filename='test.mp4')
# create tweet with images, videos, gifs, and tagged users
r = tweet('test 123', session, media=[{'file': 'image.jpeg', 'tagged_users': [123234345456], 'alt': 'some image'}])
r = tweet('test 123', session, media=['test.jpg', 'test.png', 'test.jpeg', 'test.jfif'])
r = tweet('test 123', session, media=['test.mp4'])
r = tweet('test 123', session)
# delete tweet
r = untweet(123, session)
r = retweet(1633609779745820675, session)
r = unretweet(1633609779745820675, session)
r = quote('test 123', 'elonmusk', 1633609779745820675, session)
r = comment('test 123', 1633609779745820675, session)
r = unlike(1633609779745820675, session)
r = like(1633609779745820675, session)
r = follow(50393960, session)
r = unfollow(50393960, session)
r = mute(50393960, session)
r = unmute(50393960, session)
r = enable_notifications(50393960, session)
r = disable_notifications(50393960, session)
r = block(50393960, session)
r = unblock(50393960, session)
# some hidden user attribute?
r = stats(50393960, session)
r = bookmark(1633609779745820675, session)
r = unbookmark(1633609779745820675, session)
r = unbookmark_all(1633609779745820675, session)
# update profile
update_profile_image('profile.jpg', session)
update_profile_banner('banner.jpg', session)
update_profile_info(session, name='Foo Bar', description='Test 123', location='Victoria, BC')
Scraping
User/Tweet data
from twitter.scrape import *
from twitter.login import login
usr, pwd = ..., ...
session = login(usr, pwd)
user_ids = [...]
usernames = [...]
tweet_ids = [...]
######### User Data ########
users = get_user_by_screen_name(usernames, session)
tweets = get_user_tweets(user_ids, session)
likes = get_likes(user_ids, session)
tweets_and_replies = get_tweets_and_replies(user_ids, session)
media = get_media(user_ids, session)
following = get_following(user_ids, session)
followers = get_followers(user_ids, session)
######### Tweet Data ########
tweet = get_tweet_by_rest_id(tweet_ids, session)
tweet_detail = get_tweets(tweet_ids, session)
retweeters = get_retweeters(tweet_ids, session)
favoriters = get_favoriters(tweet_ids, session)
######### Media (Images/Videos) ########
download_media(tweet_ids, session)
Search
from twitter.search import search
search(
'(#dogs OR #cats) min_retweets:500',
'min_faves:10000 @elonmusk until:2023-02-16 since:2023-02-01',
'brasil portugal -argentina',
'paperswithcode -tensorflow -tf',
'skateboarding baseball guitar',
'cheese bread butter',
'ios android',
)
- search results are output to
~/data/raw
- ~400 search results rate limiting occurs
Search Operators Reference
https://developer.twitter.com/en/docs/twitter-api/v1/rules-and-filtering/search-operators
https://developer.twitter.com/en/docs/twitter-api/tweets/search/integrate/build-a-query
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
twitter-api-client-0.2.5.tar.gz
(26.0 kB
view hashes)
Built Distribution
Close
Hashes for twitter_api_client-0.2.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b823ca56226d2ee120731ee013c5163892fdb93448e236b066410c9081f01af8 |
|
MD5 | 6969d627ef2391406f3d0c60ca2735ce |
|
BLAKE2b-256 | b68422f1df1c711dff03e3bf54eaa601580d29b773d727014962579e9b563ca9 |