threads-py


Namethreads-py JSON
Version 0.0.9 PyPI version JSON
download
home_pagehttps://github.com/junhoyeo/threads-py
SummaryUnofficial, Reverse-Engineered Python client for Meta's Threads.
upload_time2023-07-18 04:33:16
maintainer
docs_urlNone
authorJunho Yeo
requires_python>=3.8.1,<4.0
licenseMIT
keywords threads instagram facebook meta api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # [<img src="./.github/logo.jpg" width="36" height="36" />](https://github.com/junhoyeo) threads-py

[![pypi](https://img.shields.io/pypi/v/threads-py.svg?style=flat-square&labelColor=black)](https://pypi.org/project/threads-py) [![MIT License](https://img.shields.io/badge/license-MIT-blue?style=flat-square&labelColor=black)](https://github.com/junhoyeo/threads-py/blob/main/LICENSE)

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

**Looking for the TypeScript version?** _Check out **[junhoyeo/threads-api. ![](https://img.shields.io/github/stars/junhoyeo%2Fthreads-api?style=social)](https://github.com/junhoyeo/threads-api)**_

## Installation

```bash
pip install --no-cache-dir --upgrade threads-py
```

<details>
<summary><h3>🚀 Usage (Read)</h3></summary>

```python
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)
```
</details>

### 🚀 Usage (Write)

#### ✨ Text Threads

```python
from threadspy import ThreadsAPI

api = ThreadsAPI(username="username", password="password")
api.publish(caption="🤖 Hello World!")
```

#### ✨ Threads with Image

```python
api.publish(caption= '🤖 Threads with Link Image', image_path="https://github.com/junhoyeo/threads-py/raw/main/.github/logo.jpg")
```

#### ✨ Threads with Link Attachment

```python
api.publish(caption= '🤖 Threads with Link Attachment', url="https://github.com/junhoyeo/threads-py)")
```

#### ✨ Reply to Other Threads

```python
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

```python
search_parameter = "DrunkLeen"
# 💡 Uses current credentials
api.search(search_parameter)
```

#### 👍 Like/Unlike a Thread

```python
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

```python
user_id = api.get_user_id_from_username('junhoyeo')

# 💡 Uses current credentials
api.follow(user_id)
api.unfollow(user_id)
```

#### ⛔ Block/Unblock a User

```python
user_id = api.get_user_id_from_username('junhoyeo')

# 💡 Uses current credentials
api.block(user_id)
api.unblock(user_id)
```

#### 🔇 Mute/Unmute a User

```python
user_id = api.get_user_id_from_username('junhoyeo')

# 💡 Uses current credentials
api.mute(user_id)
api.unmute(user_id)
```

#### ⏚ī¸ Restrict/Unrestrict a User

```python
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

```python
user_id = api.get_user_id_from_username('junhoyeo')

# 💡 Uses current credentials
api.friendship_status(user_id)
```

#### 👉đŸģ👈đŸģ Get User Followings and Followers

```python
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

```python
# 💡 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
```


## [<img src="./.github/emojis/pushpin.png" width="30" height="30" />](https://github.com/junhoyeo) Roadmap

- [x] ✅ Read public data
  - [x] ✅ Fetch UserID(`314216`) via username(`zuck`)
  - [ ] 🚧 Read timeline feed
  - [x] ✅ Read User Profile Info
  - [x] ✅ Read list of User Threads
    - [ ] 🚧 With Pagination (If auth provided)
  - [x] ✅ Read list of User Replies
    - [ ] 🚧 With Pagination (If auth provided)
  - [x] ✅ Fetch PostID(`3140957200974444958`) via ThreadID(`CuW6-7KyXme`) or PostURL(`https://www.threads.net/t/CuW6-7KyXme`)
  - [x] ✅ Read Threads via PostID
  - [x] ✅ Read Likers in Thread via PostID
- [ ] 🚧 LangChain Agent (`threadspy.ai`)
  - [ ] 🚧 Threads Tool for LangChain
  - [ ] 📌 Link Threads & LLaMa ([@Mineru98](https://github.com/Mineru98))
  - [ ] 📌 Provide statistical analysis of posts in Threads ([@Mineru98](https://github.com/Mineru98))
- [x] ✅ Read user private data
  - [x] ✅ Get suggested users
  - [x] ✅ Read User Followers
  - [x] ✅ 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
- [x] ✅ Friendships
  - [x] ✅ Follow User
  - [x] ✅ Unfollow User
  - [x] ✅ Block User
  - [x] ✅ Unblock User
  - [x] ✅ Mute User
  - [x] ✅ Unmute User
  - [x] ✅ Restrict User
  - [x] ✅ Unrestrict User
  - [x] ✅ Check FriendshipStatus with a User
- [x] ✅ Interactions
  - [x] ✅ Like Thread
  - [x] ✅ Unlike Thread

## License

<p align="center">
  <a href="https://github.com/junhoyeo">
    <img src="./.github/labtocat.png" width="256" height="256">
  </a>
</p>

<p align="center">
  <strong>MIT Š <a href="https://github.com/junhoyeo">Junho Yeo</a></strong>
</p>

If you find this project intriguing, **please consider starring it(⭐)** or following me on [GitHub](https://github.com/junhoyeo) (I wouldn't say [Threads](https://www.threads.net/@_junhoyeo)).

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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/junhoyeo/threads-py",
    "name": "threads-py",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8.1,<4.0",
    "maintainer_email": "",
    "keywords": "threads,instagram,facebook,meta,api",
    "author": "Junho Yeo",
    "author_email": "i@junho.io",
    "download_url": "https://files.pythonhosted.org/packages/64/e1/5a3566f01298818462f803a5d654b4746ede9312e18e337c955b7f333a9f/threads_py-0.0.9.tar.gz",
    "platform": null,
    "description": "# [<img src=\"./.github/logo.jpg\" width=\"36\" height=\"36\" />](https://github.com/junhoyeo) threads-py\n\n[![pypi](https://img.shields.io/pypi/v/threads-py.svg?style=flat-square&labelColor=black)](https://pypi.org/project/threads-py) [![MIT License](https://img.shields.io/badge/license-MIT-blue?style=flat-square&labelColor=black)](https://github.com/junhoyeo/threads-py/blob/main/LICENSE)\n\n> Unofficial, Reverse-Engineered Python client for Meta's Threads.\n\n**Looking for the TypeScript version?** _Check out **[junhoyeo/threads-api. ![](https://img.shields.io/github/stars/junhoyeo%2Fthreads-api?style=social)](https://github.com/junhoyeo/threads-api)**_\n\n## Installation\n\n```bash\npip install --no-cache-dir --upgrade threads-py\n```\n\n<details>\n<summary><h3>\ud83d\ude80 Usage (Read)</h3></summary>\n\n```python\nfrom threadspy import ThreadsAPI\n\napi = ThreadsAPI()\n\nusername = \"{username}\"\n\n# get a user id\nuser_id = api.get_user_id_from_username(username)\nprint(user_id)\n\n# get a profile info\nprofile = api.get_user_profile(username, user_id=user_id)\nprint(profile)\n\n# get a profile's threads tab\nthreads = api.get_user_profile_threads(username, user_id=user_id)\nprint(threads)\n\n# get a profile's replies tab\nreplies = api.get_user_profile_replies(username, user_id=user_id)\nprint(replies)\n\n# 3-ways to get the {post_id}\nthread_id = \"CuX_UYABrr7\"\npost_id = api.get_post_id_from_thread_id(thread_id)\nprint(post_id)\n\npost_url = \"https://www.threads.net/t/CuX_UYABrr7/?igshid=MzRlODBiNWFlZA==\"\npost_id = api.get_post_id_from_url(post_url)\nprint(post_id)\n\nthread_id = \"CuX_UYABrr7\"\npost_id = api.get_post_id_from_thread_id(thread_id)\nprint(post_id)\n\n# get threads info\nthread = api.get_threads(post_id)\nprint(thread)\n\n# get who liked a thread\nlinkers = api.get_thread_likers(post_id)\nprint(linkers)\n```\n</details>\n\n### \ud83d\ude80 Usage (Write)\n\n#### \u2728 Text Threads\n\n```python\nfrom threadspy import ThreadsAPI\n\napi = ThreadsAPI(username=\"username\", password=\"password\")\napi.publish(caption=\"\ud83e\udd16 Hello World!\")\n```\n\n#### \u2728 Threads with Image\n\n```python\napi.publish(caption= '\ud83e\udd16 Threads with Link Image', image_path=\"https://github.com/junhoyeo/threads-py/raw/main/.github/logo.jpg\")\n```\n\n#### \u2728 Threads with Link Attachment\n\n```python\napi.publish(caption= '\ud83e\udd16 Threads with Link Attachment', url=\"https://github.com/junhoyeo/threads-py)\")\n```\n\n#### \u2728 Reply to Other Threads\n\n```python\nparent_post_url = 'https://www.threads.net/t/CugF-EjhQ3r'\nparent_post_id = api.get_post_id_from_url(parent_post_url) # or use `get_post_id_from_thread_id`\n\napi.publish({\n  text: '\ud83e\udd16 Beep',\n  link: 'https://github.com/junhoyeo/threads-py',\n  parent_post_id: parent_post_id,\n})\n```\n\n#### \ud83d\udd0e Search Users\n\n```python\nsearch_parameter = \"DrunkLeen\"\n# \ud83d\udca1 Uses current credentials\napi.search(search_parameter)\n```\n\n#### \ud83d\udc4d Like/Unlike a Thread\n\n```python\npost_url = 'https://www.threads.net/t/CugF-EjhQ3r'\npost_id = api.get_post_id_from_url(post_url) # or use `get_post_id_from_thread_id`\n\n# \ud83d\udca1 Uses current credentials\napi.like(postIDToLike)\napi.unlike(postIDToLike)\n```\n\n#### \ud83d\udc49 Follow/Unfollow a User\n\n```python\nuser_id = api.get_user_id_from_username('junhoyeo')\n\n# \ud83d\udca1 Uses current credentials\napi.follow(user_id)\napi.unfollow(user_id)\n```\n\n#### \u26d4 Block/Unblock a User\n\n```python\nuser_id = api.get_user_id_from_username('junhoyeo')\n\n# \ud83d\udca1 Uses current credentials\napi.block(user_id)\napi.unblock(user_id)\n```\n\n#### \ud83d\udd07 Mute/Unmute a User\n\n```python\nuser_id = api.get_user_id_from_username('junhoyeo')\n\n# \ud83d\udca1 Uses current credentials\napi.mute(user_id)\napi.unmute(user_id)\n```\n\n#### \u23f9\ufe0f Restrict/Unrestrict a User\n\n```python\nuser_id = api.get_user_id_from_username('junhoyeo')\n\n# \ud83d\udca1 Uses current credentials\napi.restrict(user_id)\napi.unrestrict(user_id)\n```\n\n#### \ud83e\uddd1\u200d\ud83e\uddb3 Check FriendshipStatus with a User\n\n```python\nuser_id = api.get_user_id_from_username('junhoyeo')\n\n# \ud83d\udca1 Uses current credentials\napi.friendship_status(user_id)\n```\n\n#### \ud83d\udc49\ud83c\udffb\ud83d\udc48\ud83c\udffb Get User Followings and Followers\n\n```python\nuser_id = api.get_user_id_from_username('junhoyeo')\n\n# \ud83d\udca1 Uses current credentials\napi.get_followings(user_id)\napi.get_followers(user_id)\n```\n\n#### \u2795 Get Suggested Users\n\n```python\n# \ud83d\udca1 Uses current credentials\napi.get_suggested_users()\n# or\napi.get_suggested_users(count=5)\n# or\napi.get_suggested_users(paging=3)\n# or\napi.get_suggested_users(count=5, paging=2)\n# \"count\" and \"paging\" parameters are optional\n# default: count = 15 \"paging\" are optional\n# default: paging = None\n```\n\n\n## [<img src=\"./.github/emojis/pushpin.png\" width=\"30\" height=\"30\" />](https://github.com/junhoyeo) Roadmap\n\n- [x] \u2705 Read public data\n  - [x] \u2705 Fetch UserID(`314216`) via username(`zuck`)\n  - [ ] \ud83d\udea7 Read timeline feed\n  - [x] \u2705 Read User Profile Info\n  - [x] \u2705 Read list of User Threads\n    - [ ] \ud83d\udea7 With Pagination (If auth provided)\n  - [x] \u2705 Read list of User Replies\n    - [ ] \ud83d\udea7 With Pagination (If auth provided)\n  - [x] \u2705 Fetch PostID(`3140957200974444958`) via ThreadID(`CuW6-7KyXme`) or PostURL(`https://www.threads.net/t/CuW6-7KyXme`)\n  - [x] \u2705 Read Threads via PostID\n  - [x] \u2705 Read Likers in Thread via PostID\n- [ ] \ud83d\udea7 LangChain Agent (`threadspy.ai`)\n  - [ ] \ud83d\udea7 Threads Tool for LangChain\n  - [ ] \ud83d\udccc Link Threads & LLaMa ([@Mineru98](https://github.com/Mineru98))\n  - [ ] \ud83d\udccc Provide statistical analysis of posts in Threads ([@Mineru98](https://github.com/Mineru98))\n- [x] \u2705 Read user private data\n  - [x] \u2705 Get suggested users\n  - [x] \u2705 Read User Followers\n  - [x] \u2705 Read User Followings\n- [ ] \ud83d\udea7 Write data (i.e. write automated Threads)\n  - [ ] \ud83d\udea7 Create new Thread with text\n    - [ ] \ud83d\udea7 Make link previews to get shown\n  - [ ] \ud83d\udea7 Create new Thread with media\n  - [ ] \ud83d\udea7 Create new Thread with multiple images\n  - [ ] \ud83d\udea7 Reply to existing Thread\n  - [ ] \ud83d\udea7 Quote Thread\n  - [ ] \ud83d\udea7 Delete Thread\n- [x] \u2705 Friendships\n  - [x] \u2705 Follow User\n  - [x] \u2705 Unfollow User\n  - [x] \u2705 Block User\n  - [x] \u2705 Unblock User\n  - [x] \u2705 Mute User\n  - [x] \u2705 Unmute User\n  - [x] \u2705 Restrict User\n  - [x] \u2705 Unrestrict User\n  - [x] \u2705 Check FriendshipStatus with a User\n- [x] \u2705 Interactions\n  - [x] \u2705 Like Thread\n  - [x] \u2705 Unlike Thread\n\n## License\n\n<p align=\"center\">\n  <a href=\"https://github.com/junhoyeo\">\n    <img src=\"./.github/labtocat.png\" width=\"256\" height=\"256\">\n  </a>\n</p>\n\n<p align=\"center\">\n  <strong>MIT \u00a9 <a href=\"https://github.com/junhoyeo\">Junho Yeo</a></strong>\n</p>\n\nIf you find this project intriguing, **please consider starring it(\u2b50)** or following me on [GitHub](https://github.com/junhoyeo) (I wouldn't say [Threads](https://www.threads.net/@_junhoyeo)).\n\nMIT License\n\nCopyright (c) 2023 Junho Yeo\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Unofficial, Reverse-Engineered Python client for Meta's Threads.",
    "version": "0.0.9",
    "project_urls": {
        "Homepage": "https://github.com/junhoyeo/threads-py",
        "Repository": "https://github.com/junhoyeo/threads-py"
    },
    "split_keywords": [
        "threads",
        "instagram",
        "facebook",
        "meta",
        "api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "28b6a0929d7b5cc6bb28b7a54a9e0b6e8dfd41493af18e4caf9c16690cc73a0c",
                "md5": "e99dbf2220cac1d12bdd32db4f8fb367",
                "sha256": "0dbd02eb706134adca210e6cbf86eb55c1099031f0448e55b28f28ac33191309"
            },
            "downloads": -1,
            "filename": "threads_py-0.0.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e99dbf2220cac1d12bdd32db4f8fb367",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.1,<4.0",
            "size": 25665,
            "upload_time": "2023-07-18T04:33:15",
            "upload_time_iso_8601": "2023-07-18T04:33:15.612053Z",
            "url": "https://files.pythonhosted.org/packages/28/b6/a0929d7b5cc6bb28b7a54a9e0b6e8dfd41493af18e4caf9c16690cc73a0c/threads_py-0.0.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "64e15a3566f01298818462f803a5d654b4746ede9312e18e337c955b7f333a9f",
                "md5": "f75d8fc5bb741d61fa9c4af3660c31b3",
                "sha256": "877177fd566db4db2e0e7c8e5c636923bf3c049b85889423879021e0fec693ef"
            },
            "downloads": -1,
            "filename": "threads_py-0.0.9.tar.gz",
            "has_sig": false,
            "md5_digest": "f75d8fc5bb741d61fa9c4af3660c31b3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.1,<4.0",
            "size": 18501,
            "upload_time": "2023-07-18T04:33:16",
            "upload_time_iso_8601": "2023-07-18T04:33:16.938217Z",
            "url": "https://files.pythonhosted.org/packages/64/e1/5a3566f01298818462f803a5d654b4746ede9312e18e337c955b7f333a9f/threads_py-0.0.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-18 04:33:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "junhoyeo",
    "github_project": "threads-py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "threads-py"
}
        
Elapsed time: 0.12283s