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