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