|
| 1 | + |
| 2 | +# Threads CLI |
| 3 | + |
| 4 | +This CLI tool allows you to interact with the Threads API to perform various actions like creating posts, |
| 5 | +getting profile information, retrieving recent posts, scheduling posts, and managing drafts. |
| 6 | +The tool is built using Python and leverages the `typer` library for command-line interface creation and the `rich` |
| 7 | +library for pretty-printing tables. |
| 8 | + |
| 9 | +## Installation |
| 10 | + |
| 11 | +1. **Clone the repository:** |
| 12 | + ```bash |
| 13 | + git clone https://github.com/your-repo/threads-cli.git |
| 14 | + cd threads-cli |
| 15 | + ``` |
| 16 | + |
| 17 | +2. **Set up a virtual environment:** |
| 18 | + ```bash |
| 19 | + python3 -m venv .venv |
| 20 | + source .venv/bin/activate |
| 21 | + ``` |
| 22 | + |
| 23 | +3. **Install the dependencies:** |
| 24 | + ```bash |
| 25 | + pip install -r requirements.txt |
| 26 | + ``` |
| 27 | + |
| 28 | +4. **Set up environment variables:** |
| 29 | + Create a `.env` file in the root directory with the following content: |
| 30 | + ```env |
| 31 | + ACCESS_TOKEN=your_access_token |
| 32 | + ``` |
| 33 | + |
| 34 | +## Usage |
| 35 | + |
| 36 | +### Commands |
| 37 | + |
| 38 | +1. **Get Profile Information:** |
| 39 | + Retrieve and display user profile information, including the last post made by the user. |
| 40 | + ```bash |
| 41 | + python main.py get_profile |
| 42 | + ``` |
| 43 | + |
| 44 | +2. **Get Recent Posts:** |
| 45 | + Retrieve the most recent posts. |
| 46 | + ```bash |
| 47 | + python main.py get_recent_posts --limit 5 |
| 48 | + ``` |
| 49 | + |
| 50 | +3. **Get Top Liked Posts:** |
| 51 | + Retrieve the top liked posts of all time or within a specific time range. |
| 52 | + ```bash |
| 53 | + python main.py get_top_liked_posts --limit 5 --time-range 2w |
| 54 | + ``` |
| 55 | + |
| 56 | +4. **Create a Text Post:** |
| 57 | + Create a post with text. |
| 58 | + ```bash |
| 59 | + python main.py create_text_post "This is a text post." |
| 60 | + ``` |
| 61 | + |
| 62 | +5. **Create an Image Post:** |
| 63 | + Create a post with an image. |
| 64 | + ```bash |
| 65 | + python main.py create_image_post "This is an image post." "https://example.com/image.jpg" |
| 66 | + ``` |
| 67 | + |
| 68 | +6. **Get Latest Replies:** |
| 69 | + Retrieve the latest replies for a specific media post. |
| 70 | + ```bash |
| 71 | + python main.py get_latest_replies --media-id <media_id> --limit 5 |
| 72 | + ``` |
| 73 | + |
| 74 | +7. **Send a Reply:** |
| 75 | + Send a reply to a specific media post. |
| 76 | + ```bash |
| 77 | + python main.py send_reply --media-id <media_id> --text "This is a reply." |
| 78 | + ``` |
| 79 | + |
| 80 | +8. **Schedule a Post:** |
| 81 | + Schedule a post with text at a specific time. |
| 82 | + ```bash |
| 83 | + python main.py schedule_post --text "This is a scheduled post." --post-time "2024-06-22 23:22:00" |
| 84 | + ``` |
| 85 | + |
| 86 | +9. **Create a Draft:** |
| 87 | + Create a draft with text. |
| 88 | + ```bash |
| 89 | + python main.py create_draft "This is a draft." |
| 90 | + ``` |
| 91 | + |
| 92 | +10. **Get Drafts:** |
| 93 | + Retrieve all drafts. |
| 94 | + ```bash |
| 95 | + python main.py get_drafts |
| 96 | + ``` |
| 97 | + |
| 98 | +11. **Send a Draft:** |
| 99 | + Send a draft with a specific ID and remove it from drafts. |
| 100 | + ```bash |
| 101 | + python main.py send_draft --draft-id 1 |
| 102 | + ``` |
| 103 | + |
| 104 | +## Additional Information |
| 105 | + |
| 106 | +### Dependencies |
| 107 | +- `typer` |
| 108 | +- `requests` |
| 109 | +- `rich` |
| 110 | +- `python-dotenv` |
| 111 | + |
| 112 | +### Environment Variables |
| 113 | +- `ACCESS_TOKEN`: Your Threads API access token. |
| 114 | + |
| 115 | +## Development |
| 116 | + |
| 117 | +Feel free to contribute to this project by creating pull requests. Make sure to follow the standard coding guidelines and thoroughly test your changes. |
| 118 | + |
| 119 | +### Things to do |
| 120 | +- [ ] Add tests for the CLI commands. |
| 121 | +- [ ] Add support for creating polls. |
| 122 | +- [ ] Validate that creating videos/image posts works |
| 123 | + |
0 commit comments