Unofficial, Reverse-Engineered Python API for Meta's Threads.
Looking for the TypeScript version? Check out junhoyeo/threads-api.
pip install --no-cache-dir --upgrade threads-py
from threadspy import ThreadsAPI
api = ThreadsAPI()
from threadspy import ThreadsAPI
api = ThreadsAPI(
username="Your-Username"
password="Your-Password"
token="You-Token" # optional (if you're already authenticated)
)
- π’ Read public data
- β Fetch User ID
- β Read User Profile Info
- β
Read list of User Threads
- π§ With Pagination (If auth provided)
- β
Read list of User Replies
- π§ With Pagination (If auth provided)
- β Fetch Post ID
- β Read A Single Thread
- β Get Thread Likes
- π Read user private data
- β Read User Followings
- β Read User Followers
- β Get suggested users
- β Search Query
- π§ Read User Timeline Feed
- π Write Private Data (Authentication Required)
- β
(Create New Thrad Or Reply To Eexisting Thread)[#create-new-thrad-or-reply-to-eexisting-thread]
- π§ Make link previews to get shown
- β Delete Thread
- π§ Quote Thread
- β
(Create New Thrad Or Reply To Eexisting Thread)[#create-new-thrad-or-reply-to-eexisting-thread]
- π (Friendship Actions)[#friendship-actions-authentication-required]
- β Follow User
- β Unfollow User
- β Block User
- β Unblock User
- β Mute User
- β Unmute User
- β Restrict User
- β Unrestrict User
- β Check Friendship Status With Another Users
- π Interactions (Authentication Required)
- π§ LangChain Agent (
threadspy.ai
)
user_id = api.get_user_id_from_username(username)
user_profile = api.get_user_profile(username, user_id)
Parameters | Description | Type | Required | Default Value |
---|---|---|---|---|
username |
Target username | String | Yes | - |
user_id |
Target User ID | String | No | None |
user_threads = api.get_user_profile_threads(username, user_id)
Parameters | Description | Type | Required | Default Value |
---|---|---|---|---|
username |
Target username | String | Yes | - |
user_id |
Target User ID | String | No | None |
user_replies = api.get_user_profile_replies(username, user_id)
Parameters | Description | Type | Required | Default Value |
---|---|---|---|---|
username |
Target username | String | Yes | - |
user_id |
Target User ID | String | No | None |
post_id = api.get_post_id_from_thread_id(thread_id)
via Post URL E.g."https://www.threads.net/t/CuW6-7KyXme":
post_id = api.get_post_id_from_url(post_url)
post_url = 'https://www.threads.net/t/CugF-EjhQ3r'
post_id = api.get_post_id_from_url(post_url)
single_thread = api.get_threads(post_id)
thread_likes = api.get_thread_likers(post_id)
user_followers = api.get_followings(user_id)
user_followings = api.get_followers(user_id)
suggested_users = api.get_suggested_users(count, paging)
Parameters | Description | Type | Required | Default Value |
---|---|---|---|---|
count |
Number of suggested users | Integer | No | 15 |
paging |
Page number | Integer | No | None |
thread_likes = api.search(search_parameter)
boolean_response = api.publish(count, image_path, url, parent_post_id)
Parameters | Description | Type | Required | Default Value |
---|---|---|---|---|
caption |
Text to post in Thread | String | Yes | 15 |
image_path |
Image Path to post in Thread | String | No | None |
url |
Link to post in Thread | String | No | None |
parent_post_id |
Post ID | String | No | None |
- Text Threads:
api.publish(caption="π€ Hello World!")
- Threads with Image:
api.publish(
caption= 'π€ Threads with Link Image',
image_path="https://github.com/junhoyeo/threads-py/raw/main/.github/logo.jpg"
)
- Threads with Link Attachment:
api.publish(
caption= 'π€ Threads with Link Image',
url="https://github.com/junhoyeo/threads-py"
)
Reply to Other Threads:
parent_post_url = 'https://www.threads.net/t/CugF-EjhQ3r'
parent_post_id = api.get_post_id_from_url(parent_post_url) # or use `get_post_id_from_thread_id`
api.publish({
text: 'π€ Beep',
link: 'https://github.com/junhoyeo/threads-py',
parent_post_id: parent_post_id,
})
boolean_response = api.delete_thread(post_id)
boolean_response = api.follow(user_id)
boolean_response = api.unfollow(user_id)
boolean_response = api.block(user_id)
boolean_response = api.unblock(user_id)
boolean_response = api.mute(user_id)
boolean_response = api.unmute(user_id)
boolean_response = api.restrict(user_id)
boolean_response = api.unrestrict(user_id)
friendship_status = api.friendship_status(user_id)
boolean_response = api.like(post_id)
boolean_response = api.unlike(post_id)
boolean_response = api.repost_thread(post_id)
boolean_response = api.unrepost_thread(post_id)
Junho Yeo π» |
iamiks π» |
DrunkLeen π» |
Asharaf Ali π» |
mirageoasis π» |
MIT Β© Junho Yeo
If you find this project intriguing, please consider starring it(β) or following me on GitHub (I wouldn't say Threads).