Skip to main content

threads-py

pypi MIT License

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")
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)
    • 🚧 Threads Tool for LangChain
    • 📌 Link Threads & LLaMa (@Mineru98)
    • 📌 Provide statistical analysis of posts in Threads (@Mineru98)
  • ✅ 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(⭐) or following me on GitHub (I wouldn't say Threads).

MIT License

Copyright (c) 2023 Junho Yeo

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Metadata

Release files for threads-py 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for threads-py 0.0.9
File Size Uploaded Provenance Actions
threads_py-0.0.9.tar.gz 18.5 kB Without provenance Details for threads_py-0.0.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for threads-py 0.0.9
File Interpreter ABI Platform Actions
threads_py-0.0.9-py3-none-any.whl Python 3 none any Details for threads_py-0.0.9-py3-none-any.whl

Total release size: 44.2 kB

Release files / threads_py-0.0.9.tar.gz

Download URL threads_py-0.0.9.tar.gz
Size 18.5 kB
Tags Source
SHA-256 checksum
How to use checksums
877177fd566db4db2e0e7c8e5c636923bf3c049b85889423879021e0fec693ef
BLAKE2b-256 checksum
How to use checksums
64e15a3566f01298818462f803a5d654b4746ede9312e18e337c955b7f333a9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.4 Darwin/22.5.0

Release files / threads_py-0.0.9-py3-none-any.whl

Download URL threads_py-0.0.9-py3-none-any.whl
Size 25.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0dbd02eb706134adca210e6cbf86eb55c1099031f0448e55b28f28ac33191309
BLAKE2b-256 checksum
How to use checksums
28b6a0929d7b5cc6bb28b7a54a9e0b6e8dfd41493af18e4caf9c16690cc73a0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.4 Darwin/22.5.0

Security for threads-py 0.0.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page