Skip to main content

Unofficial, Reverse-Engineered Python client for Meta's Threads.

Project description

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 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,
})

✨ Like/Unlike a Thread (from v0.0.8)

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 (from v0.0.8)

user_id_to_follow = api.get_user_id_from_username('junhoyeo')

# 💡 Uses current credentials
api.follow(user_id_to_follow)
api.unfollow(user_id_to_follow)

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
    • 🚧 Read User Followers
    • 🚧 Read User Followings
  • 🚧 LangChain Agent (threadspy.ai)
    • 🚧 Threads Tool for LangChain
    • 📌 Link Threads & LLaMa (@Mineru98)
    • 📌 Provide statistical analysis of posts in Threads (@Mineru98)
  • ✅ 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
  • ✅ 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

threads_py-0.0.8.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

threads_py-0.0.8-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file threads_py-0.0.8.tar.gz.

File metadata

  • Download URL: threads_py-0.0.8.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.3 Darwin/22.1.0

File hashes

Hashes for threads_py-0.0.8.tar.gz
Algorithm Hash digest
SHA256 332f355484529eb15f3b8520769c89a980bc38a8b1f07cd24c3bdb35d9d616c3
MD5 4bd34efe7b7880f8947422dd816104bb
BLAKE2b-256 5141805490da688ab8487e9680f7ca3f7aa6d2d10b02cf5af309c64bd9c4a549

See more details on using hashes here.

File details

Details for the file threads_py-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: threads_py-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.3 Darwin/22.1.0

File hashes

Hashes for threads_py-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 4b3e6e3b9979286bc430cf35f62e0bf3f12a3e4e56e8f3253d2970a1170ed9c2
MD5 ada5031017b2ca3a594149061edbe9a0
BLAKE2b-256 92a959928a3ee7d1868499df881e95d9996769d76f49513e1a6602c1e0a04dab

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page