awshttp
Minimal Python library for making AWS SigV4 signed HTTP requests.
Perfect for Lambda functions and scripts that need to call AWS APIs with automatic credential detection.
Automate AWS Console actions programmatically! Capture API calls from your browser's Network tab and replay them in Python.
Installation
# Using pip
pip install awshttp
# Using uv (recommended)
uv pip install awshttp
Usage
import awshttp
# GET request
response = awshttp.get(
uri='https://my-api.execute-api.us-east-1.amazonaws.com/prod/endpoint',
service='execute-api'
)
print(response.json())
# POST request
response = awshttp.post(
uri='https://my-api.execute-api.us-east-1.amazonaws.com/prod/endpoint',
service='execute-api',
data='{"key": "value"}',
headers={'content-type': 'application/json'}
)
# PUT request with JSON helper
response = awshttp.put_json(
uri='https://uxc.us-east-1.api.aws/v1/account-color',
service='uxc',
region='us-east-1',
data={'color': 'green'}
)
# Or use the main request function
response = awshttp.request(
uri='https://my-api.execute-api.us-east-1.amazonaws.com/prod/endpoint',
method='POST',
service='execute-api',
data='{"key": "value"}',
headers={'content-type': 'application/json'}
)
Features
- Automatic AWS credential detection (IAM roles, environment variables, ~/.aws/credentials)
- Support for all AWS services (including undocumented Console APIs)
- Simple requests-like interface
- Retry logic with exponential backoff
- JSON helpers for API calls
- Environment variable configuration
- Minimal dependencies (boto3, requests)
Automating Web Console Actions
Many AWS Console features don't have official CLI/SDK support. Use browser DevTools to capture the API calls:
- Open AWS Console in your browser
- Open DevTools (F12) → Network tab
- Perform the action you want to automate
- Find the API call in the Network tab
- Copy the URL, method, headers, and body
- Replicate with awshttp!
Example: Change AWS Console account color
import awshttp
# This API isn't in the AWS SDK, but we can call it directly!
response = awshttp.put_json(
uri='https://uxc.us-east-1.api.aws/v1/account-color',
service='uxc', # Service name from the URL
region='us-east-1',
data={'color': 'green'}
)
print(f"Status: {response.status_code}")
print(f"Response: {response.text}")
Tips for finding service names:
- Look at the URL:
https://SERVICE.REGION.api.aws/... - Common services:
uxc(console UI),execute-api(API Gateway),s3,ec2 - Check the
authorizationheader in DevTools for the service name
Advanced usage with retry:
# Retry failed requests automatically
@awshttp.with_retry(retries=5, backoff=2.0)
def reliable_api_call():
return awshttp.post_json(
uri='https://api.example.com/endpoint',
service='execute-api',
data={'action': 'process'},
timeout=30
)
response = reliable_api_call()
API Reference
awshttp.request(uri, method='GET', service='execute-api', region=None, headers=None, data='', verify=True, allow_redirects=False, timeout=None, session=None)
Main function for making signed AWS requests.
Parameters:
uri(str): Full URL to requestmethod(str): HTTP method (GET, POST, PUT, DELETE, PATCH)service(str): AWS service name for signingregion(str | None): AWS region (auto-detects if None)headers(dict | None): HTTP headersdata(str | bytes): Request bodyverify(bool): Verify SSL certificatesallow_redirects(bool): Follow redirectstimeout(float | None): Request timeout in secondssession(boto3.Session | None): Boto3 session for credential reuse
Returns: requests.Response object
Convenience methods
awshttp.get(uri, **kwargs)- GET requestawshttp.post(uri, data='', **kwargs)- POST requestawshttp.put(uri, data='', **kwargs)- PUT requestawshttp.delete(uri, **kwargs)- DELETE requestawshttp.patch(uri, data='', **kwargs)- PATCH requestawshttp.post_json(uri, data={}, **kwargs)- POST with JSON serializationawshttp.put_json(uri, data={}, **kwargs)- PUT with JSON serialization
Retry decorator
@awshttp.with_retry(retries=3, backoff=1.0)
def my_api_call():
return awshttp.get('https://api.example.com/endpoint')
Environment variables
AWSHTTP_TIMEOUT- Default timeout in secondsAWSHTTP_VERIFY_SSL- SSL verification (true/false)
Project Structure
awshttp/
├── awshttp/ # Main package
├── tests/ # Test suite
├── examples/ # Usage examples
├── docs/ # Documentation
└── .github/ # GitHub Actions workflows
Development
# Using uv (recommended)
uv sync --all-extras
uv run pytest tests/
# Or using make
make dev # Install with dev dependencies
make test # Run tests
make build # Build package
License
MIT
Metadata
Release files for awshttp 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| awshttp-0.1.2.tar.gz | 6.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| awshttp-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.0 kB
Release files / awshttp-0.1.2.tar.gz
| Download URL | awshttp-0.1.2.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ce9a157cc71d69f592f7421b1a5fd8a74879c8ba64010f79515feea2a8d93065
|
|
BLAKE2b-256 checksum How to use checksums |
cc38a0f532df213366a9238c217acdc1b42104bfea04267c589d6843ac38bd72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / awshttp-0.1.2-py3-none-any.whl
| Download URL | awshttp-0.1.2-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b9fbc50bdfba7ffe1a884aa9240edc62cddcf22fae943af93e4f1e7dc0885099
|
|
BLAKE2b-256 checksum How to use checksums |
72fa4b319f34605fb2a54145356eafeaf63301f13f27c9fb3a4c38580039a89c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|