threads-py
Unofficial, Reverse-Engineered Python client for Meta's Threads.
Looking for the TypeScript version? Check out junhoyeo/threads-api.
Installation
pip install --no-cache-dir --upgrade threads-py
đ Usage (Read)
from threadspy import ThreadsAPI
api = ThreadsAPI()
username = "{username}"
# get a user id
user_id = api.get_user_id_from_username(username)
print(user_id)
# get a profile info
profile = api.get_user_profile(username, user_id=user_id)
print(profile)
# get a profile's threads tab
threads = api.get_user_profile_threads(username, user_id=user_id)
print(threads)
# get a profile's replies tab
replies = api.get_user_profile_replies(username, user_id=user_id)
print(replies)
# 3-ways to get the {post_id}
thread_id = "CuX_UYABrr7"
post_id = api.get_post_id_from_thread_id(thread_id)
print(post_id)
post_url = "https://www.threads.net/t/CuX_UYABrr7/?igshid=MzRlODBiNWFlZA=="
post_id = api.get_post_id_from_url(post_url)
print(post_id)
thread_id = "CuX_UYABrr7"
post_id = api.get_post_id_from_thread_id(thread_id)
print(post_id)
# get threads info
thread = api.get_threads(post_id)
print(thread)
# get who liked a thread
linkers = api.get_thread_likers(post_id)
print(linkers)
đ Usage (Write)
⨠Text Threads
from threadspy import ThreadsAPI
api = ThreadsAPI(username="username", password="password")
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 Attachment', 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,
})
đ Search Users
search_parameter = "DrunkLeen"
# đĄ Uses current credentials
api.search(search_parameter)
đ Like/Unlike a Thread
post_url = 'https://www.threads.net/t/CugF-EjhQ3r'
post_id = api.get_post_id_from_url(post_url) # or use `get_post_id_from_thread_id`
# đĄ Uses current credentials
api.like(postIDToLike)
api.unlike(postIDToLike)
đ Follow/Unfollow a User
user_id = api.get_user_id_from_username('junhoyeo')
# đĄ Uses current credentials
api.follow(user_id)
api.unfollow(user_id)
â Block/Unblock a User
user_id = api.get_user_id_from_username('junhoyeo')
# đĄ Uses current credentials
api.block(user_id)
api.unblock(user_id)
đ Mute/Unmute a User
user_id = api.get_user_id_from_username('junhoyeo')
# đĄ Uses current credentials
api.mute(user_id)
api.unmute(user_id)
âšī¸ Restrict/Unrestrict a User
user_id = api.get_user_id_from_username('junhoyeo')
# đĄ Uses current credentials
api.restrict(user_id)
api.unrestrict(user_id)
đ§âđĻŗ Check FriendshipStatus with a User
user_id = api.get_user_id_from_username('junhoyeo')
# đĄ Uses current credentials
api.friendship_status(user_id)
đđģđđģ Get User Followings and Followers
user_id = api.get_user_id_from_username('junhoyeo')
# đĄ Uses current credentials
api.get_followings(user_id)
api.get_followers(user_id)
â Get Suggested Users
# đĄ Uses current credentials
api.get_suggested_users()
# or
api.get_suggested_users(count=5)
# or
api.get_suggested_users(paging=3)
# or
api.get_suggested_users(count=5, paging=2)
# "count" and "paging" parameters are optional
# default: count = 15 "paging" are optional
# default: paging = None
Roadmap
-
â Read public data-
â Fetch UserID(314216
) via username(zuck
) -
đ§ Read timeline feed -
â 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 PostID(3140957200974444958
) via ThreadID(CuW6-7KyXme
) or PostURL(https://www.threads.net/t/CuW6-7KyXme
) -
â Read Threads via PostID -
â Read Likers in Thread via PostID
-
-
đ§ LangChain Agent (threadspy.ai
) -
â Read user private data-
â Get suggested users -
â Read User Followers -
â Read User Followings
-
-
đ§ Write data (i.e. write automated Threads)-
đ§ Create new Thread with text-
đ§ Make link previews to get shown
-
-
đ§ Create new Thread with media -
đ§ Create new Thread with multiple images -
đ§ Reply to existing Thread -
đ§ Quote Thread -
đ§ Delete Thread
-
-
â Friendships-
â Follow User -
â Unfollow User -
â Block User -
â Unblock User -
â Mute User -
â Unmute User -
â Restrict User -
â Unrestrict User -
â Check FriendshipStatus with a User
-
-
â Interactions-
â Like Thread -
â Unlike Thread
-
License
MIT Š Junho Yeo
If you find this project intriguing, please consider starring it(