Threads Post
A Python module to handle single, carousel, and reply posts on Meta’s Threads using the Graph API.
This module wraps functionality such as creating containers, checking status, publishing posts, and replying to posts in a class-based interface.
Table of Contents
Features
- Single Post: Create a simple text or single-media post.
- Carousel Post: Create a multi-media (up to 10 items) carousel post.
- Replies: Reply to existing posts with either single or carousel posts.
- Status Checks: Automatically checks for processing completion (videos, images).
Installation
-
Clone or Download the repository:
git clone https://github.com/Mr-SuperInsane/ThreadsPostModule.git
or download the ZIP file and extract it.
-
Install the dependencies:
pip install -r requirements.txt
Make sure you have Python 3.7+ installed.
Usage
-
Import the Module:
from threads_post import ThreadsPost
-
Instantiate and Call:
# Create an instance poster = ThreadsPost() # Prepare your post_data post_data = { "accessToken": "<your_access_token>", "userId": "<threads_username>", "mainPost": { "content": "Hello, Threads!", "media": ["<image_or_video_url>"] }, "replyPost": [ { "content": "This is a reply", "media": ["<image_or_video_url>"] } # ... more replies if needed ] } # Post poster.post(post_data)
-
Check Logs:
The module prints out status information (e.g., container IDs, creation times) which you can log or debug.
Example
Here’s a minimal code example that uses ThreadsPost:
from threads_post import ThreadsPost
def main():
# Replace these with your own valid access token, user ID, etc.
post_data = {
"accessToken": "YOUR_LONG_ACCESS_TOKEN",
"userId": "your_threads_username",
"mainPost": {
"content": "My first Threads Post via the API!",
"media": []
},
# Optional: Replies
"replyPost": [
{
"content": "This is a reply to my post",
"media": []
}
]
}
# Create a ThreadsPost instance and make the post
poster = ThreadsPost()
poster.post(post_data)
if __name__ == "__main__":
main()
- Run the above script (
python main.py). - Observe the console output for created container IDs, published post IDs, etc.
API Reference
class ThreadsPost
ThreadsPost()
Constructor; initializes any default configurations.
ThreadsPost.post(post_data)
Main entry point to create a single or carousel Threads post (and optionally create replies).
- Parameters:
post_data: Dictionary with required fields:accessToken(str): Valid Threads Graph API access token.userId(str): Threads username or ID.mainPost(dict): Contains the main post’s content and media list.content(str, optional): Text to post.media(list, optional): URLs of images or videos.
replyPost(list, optional): A list of replies, each a dict ofcontentandmedia.
- Raises:
ValueErrorif the required fields are missing or invalid.Exceptionif the API calls fail or time out.
ThreadsPost.singlePost(access_token, apiUserId, content, media, status, user_id)
Handles single media or text-only post creation.
ThreadsPost.carouselPost(access_token, apiUserId, content, media, status, user_id)
Handles multi-media carousel post creation.
ThreadsPost.replyPost(access_token, apiUserId, replyPostData, id)
Handles posting replies (both single and carousel).
ThreadsPost.get_api_user_id(access_token)
Retrieves the user ID from the provided access token.
ThreadsPost.checkStatus(access_token, container_id, media_type)
Checks the status of media processing up to a specified timeout (3 minutes).
Happy Posting on Threads!
Metadata
Release files for ThreadsPost 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| threadspost-0.0.1.tar.gz | 7.5 kB | Without provenance | Details for threadspost-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ThreadsPost-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for ThreadsPost-0.0.1-py3-none-any.whl |
Total release size: 15.5 kB
Release files / threadspost-0.0.1.tar.gz
| Download URL | threadspost-0.0.1.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ff297bf0b7e2a3cd3c88b2b526d82e74bdefbebaa241a03626dfbc8782bda39f
|
|
BLAKE2b-256 checksum How to use checksums |
843790a83c42a60751e77c5d04402e03d2a9019a09404d6357fd6b0fa49a9f80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.9
|
Release files / ThreadsPost-0.0.1-py3-none-any.whl
| Download URL | ThreadsPost-0.0.1-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6a11ee682b007a8a281121fa06b76666f8e834f86630d019449413cee88d6bb3
|
|
BLAKE2b-256 checksum How to use checksums |
12c80dfa97aa041046639032e96785a607c79c3985205bb937adae4fada78689
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.9
|
Security for ThreadsPost 0.0.1
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.