A simple Python application that allows you to post to X.com without opening the website, using the Twitter API v2.
- Web interface to compose and post tweets
- Command-line interface for quick posting
- Character count validation (280 limit)
- Feedback on successful posts or errors
- No need to open X.com in your browser
- Python 3.8 or higher
- Twitter Developer Account with API credentials
-
Clone this repository:
git clone https://github.com/nishantkumar1292/x-poster.git cd x-poster -
Create and activate a virtual environment:
python -m venv venv # On macOS/Linux source venv/bin/activate # On Windows venv\Scripts\activate
-
Install the required dependencies:
pip install -r requirements.txt
-
Create a
.envfile with your Twitter API credentials:cp .env.sample .env
-
Edit the
.envfile with your actual Twitter API credentials.
- Apply for a Twitter Developer account at https://developer.twitter.com/
- Create a new project and app
- Enable User Authentication Settings in your app and configure it with OAuth 2.0
- Generate API keys and tokens (you need the Bearer Token and OAuth 1.0a tokens)
- Copy these credentials to your
.envfile
Note: X API offers different tiers for API access:
- Free tier: Allows posting up to 1,500 tweets per month
- Basic tier ($100/month): Increases limit to 3,000 tweets per month and adds 10,000 pull requests
- Pro tier ($5,000/month): Offers 300,000 tweets and 1,000,000 pull requests
- Enterprise tier: Custom pricing and features
-
Run the application:
python app.py
-
Open your web browser and go to http://localhost:5000
-
Type your post and click "Post" to send it to X.com
You can also post directly from the command line:
-
Using direct command with content:
./cli.py "Your post content here" -
Or using interactive mode (just run without arguments):
./cli.py
Then type your post and press Enter twice to submit.
The project includes a linting script to check and maintain code quality:
-
To check for linting issues (including missing newlines at end of files):
./lint.py
-
To automatically fix formatting issues where possible:
./lint.py --fix
The linting script checks for:
- Files missing a final newline
- Code style issues using flake8
- Formatting issues using black
.
├── app.py # Flask web application
├── cli.py # Command-line interface
├── lint.py # Linting and code quality script
├── requirements.txt # Python dependencies
├── .env.sample # Template for environment variables
├── templates/ # HTML templates
│ └── index.html # Main web interface
├── LICENSE # MIT License
└── README.md # This documentation
Here are some exciting features we're considering for future releases:
- Support for posting images and media
- Thread creation and management
- Quote tweets and replies (not sure if this is possible!!)
- Schedule tweets for future posting
- Draft saving and management
- Dark/Light theme support
- Rich text editor with formatting options
- Emoji picker integration
- Character counter with visual feedback
- Keyboard shortcuts for quick posting
- Hashtag suggestions and trending topics
- Auto-thread creation for long posts (incase the account does not have premium subscription)
- Integration with other social media platforms (like Instagram, Facebook, etc.). We might need to change the name then!!
Feel free to contribute to any of these features or suggest new ones!
Contributions are welcome! Please feel free to submit a Pull Request.
For contributing:
- Fork the repository
- Create your feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add some amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Run the linting checks:
./lint.py --fix - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
This tool is designed for personal use. Make sure to comply with X.com's Terms of Service when using this application.