Request Forge Documentation
Welcome to Request Forge
Request Forge is a production-ready, thread-safe Request Forge library for Python with advanced features including:
✅ Automatic Retry Strategies - Exponential backoff, circuit breaker patterns
✅ Token Management - Automatic token caching, refresh, and expiration handling
✅ Multi-Step Authentication - Pipeline-based authentication for complex OAuth flows
✅ Lifecycle Hooks - Extensible request/response interception
✅ Thread-Safe - Safe for use in multi-threaded environments (Django, Flask, FastAPI)
✅ Comprehensive Error Handling - Rich exception hierarchy with detailed context
✅ Type Hints - Full type annotations for IDE autocomplete
Quick Example
from requestforge import HttpClient, HttpClientConfigBuilder
# Create configured client
config = (
HttpClientConfigBuilder()
.with_base_url('https://api.example.com')
.with_retry(max_retries=3)
.with_logging()
.build()
)
client = HttpClient(config)
# Make requests
response = client.get('/users/1')
if response.is_success:
user = response.json()
print(f"User: {user['name']}")
Table of Contents
Getting Started
User Guide
API Reference
Examples
- Basic Requests Examples
- Simple GET Request
- GET with Query Parameters
- POST Request with JSON
- POST with Form Data
- PUT Request (Update Resource)
- PATCH Request (Partial Update)
- DELETE Request
- Custom Headers
- Per-Request Headers
- Request Timeout
- Handling Different Status Codes
- File Upload
- Multiple File Upload
- Basic Authentication
- API Key Authentication
- Bearer Token Authentication
- Response Parsing
- Using Context Manager
- Request Metadata
- Converting to cURL
- Error Handling
- Batch Requests
- Rate Limiting Handling
- Complete Example: REST API Client
- See Also
- OAuth2 Flow Examples
- Multi-Step Authentication Examples
- Custom Retry Examples
- Django Integration Examples
Architecture
Development
Features
Core Features
Clean API: Intuitive interface for all HTTP methods
Thread-Safe: Connection pooling and thread-local sessions
Builder Pattern: Fluent configuration interface
Context Managers: Clean resource management
Type Hints: Full type annotations
Authentication
Token Management: Automatic caching and refresh
Multi-Step Pipelines: Chain multiple auth steps
Auto-Retry on 401: Automatic token refresh and retry
Multiple Auth Types: Bearer, API Key, Basic, Custom
Retry Strategies
Exponential Backoff: Configurable with jitter
Circuit Breaker: Prevent cascade failures
Custom Strategies: Implement your own logic
Status Code Retry: Retry on specific HTTP codes