A lightweight command-line interface for making HTTP requests. Built with Python, this tool provides an easy way to make GET, POST, PUT, PATCH and DELETE requests with support for JSON data and customizable timeouts.
- Simple command-line interface
- Case-insensitive commands (GET/get, POST/post etc.)
- Support for GET, PUT, POST, PATCH and DELETE requests
- JSON data handling for POST requests
- Customizable timeout settings
- Detailed response output
- Status code
- Response headers
- Response body
- Comprehensive error handling
- Built-in help system
- Python 3.7 or higher
- pip (Python package installer)
- virtualenv (recommended)
- Clone the repository:
git clone https://github.com/yourusername/http-cli.git
cd http-cli
- Create and activate a virtual environment (recommended):
# Windows
python -m venv venv
venv\Scripts\activate
# Linux/MacOS
python3 -m venv venv
source venv/bin/activate
- Install the package in development mode:
pip install -e .
# Make a GET request
http_cli GET https://api.example.com
# Make a POST request with JSON data
http_cli POST https://api.example.com -d '{"key": "value"}'
# Update a resource with PUT
http_cli PUT https://api.example.com/users/1 -d '{"name": "John"}'
# Partially update with PATCH
http_cli PATCH https://api.example.com/users/1 -d '{"email": "[email protected]"}'
# Delete a resource
http_cli DELETE https://api.example.com/users/1
# Show help message
http_cli HELP
usage: http_cli GET [-h] [-t TIMEOUT] url
positional arguments:
url Target URL
options:
-h, --help show this help message and exit
-t TIMEOUT, --timeout TIMEOUT
Request timeout in seconds (default: 30)
usage: http_cli POST [-h] [-t TIMEOUT] [-d DATA] url
positional arguments:
url Target URL
options:
-h, --help show this help message and exit
-t TIMEOUT, --timeout TIMEOUT
Request timeout in seconds (default: 30)
-d DATA, --data DATA R|JSON data for request body. Example: '{"key": "value"}'
usage: http_cli PUT [-h] [-t TIMEOUT] [-d DATA] url
positional arguments:
url Target URL
options:
-h, --help show this help message and exit
-t TIMEOUT, --timeout TIMEOUT
Request timeout in seconds (default: 30)
-d DATA, --data DATA R|JSON data for request body. Example: '{"key": "value"}'
usage: http_cli PATCH [-h] [-t TIMEOUT] [-d DATA] url
positional arguments:
url Target URL
options:
-h, --help show this help message and exit
-t TIMEOUT, --timeout TIMEOUT
Request timeout in seconds (default: 30)
-d DATA, --data DATA R|JSON data for request body. Example: '{"key": "value"}'
usage: http_cli DELETE [-h] [-t TIMEOUT] url
positional arguments:
url Target URL
options:
-h, --help show this help message and exit
-t TIMEOUT, --timeout TIMEOUT
Request timeout in seconds (default: 30)
Status Code: 200
Headers:
content-type: application/json
cache-control: no-cache
...
Response Body:
{
"data": {
...
}
}
The CLI handles various types of errors:
- Connection errors
- Invalid JSON data
- HTTP response errors
- Request timeout errors
- Keyboard interrupts (Ctrl+C)
All errors are displayed with descriptive messages to help diagnose the issue.
- 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)
- Open a Pull Request
- Command not found:
- Make sure the package is installed (
pip list | findstr http-cli
) - Ensure your virtual environment is activated
- Make sure the package is installed (
- Import errors:
- Try reinstalling the package:
pip install -e .
- Make sure you're using the correct Python environment
- Try reinstalling the package:
- JSON errors:
- Verify your JSON data is properly formatted
- Use single quotes around the entire JSON string and double quotes inside
This project is licensed under the Apache License, Version 2.0 - see the LICENSE file for details.