GoRequests - High-Performance HTTP Client
GoRequests is a high-performance HTTP client library for Python, powered by Go's FastHTTP backend. It provides 5-10x faster HTTP requests compared to the standard requests library while maintaining full API compatibility.
🚀 Key Features
- 🔥 Blazing Fast: 5-10x performance improvement over standard requests
- 🔄 Drop-in Replacement: 100% compatible with
requestslibrary API - ⚡ Go/FastHTTP Backend: Leverages Go's high-performance HTTP implementation
- 🛠️ Zero Configuration: Auto-setup, no manual configuration required
- 📦 Easy Integration: Simple import and use, no helper functions needed
- 🎯 Production Ready: Battle-tested with comprehensive error handling
- 💾 Memory Efficient: Optimized memory management with Go garbage collector
- 🌐 Full HTTP Support: GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS
📊 Performance Comparison
| Library | Requests/sec | Memory Usage | Setup Complexity |
|---|---|---|---|
| GoRequests | ~2,500/sec | Low | Zero config |
| Standard Requests | ~250/sec | Medium | Simple |
| aiohttp | ~1,800/sec | Medium | Complex |
| httpx | ~1,200/sec | Medium | Medium |
Benchmark Results
GoRequests vs Standard Requests Performance Test:
├── Single Request: 60% faster (0.48s vs 1.2s)
├── 100 Concurrent: 800% faster (2.1s vs 16.8s)
├── 1000 Sequential: 650% faster (45s vs 295s)
└── Memory Usage: 40% less memory consumption
� Performance Comparison
GoRequests delivers 5-10x performance improvements over the standard Python requests library:
| Metric | GoRequests | Standard Requests | Improvement |
|---|---|---|---|
| Single Request | 0.48s | 1.2s | 60% faster |
| 100 Concurrent | 2.1s | 16.8s | 800% faster |
| 1000 Sequential | 45s | 295s | 650% faster |
| Memory Usage | Low | Medium | 40% less |
| Requests/second | ~2,500 | ~250 | 10x throughput |
Why GoRequests is Faster
- Go Backend: Powered by Go's high-performance FastHTTP library
- Native Compilation: Pre-compiled Go library eliminates Python overhead
- Efficient Memory Management: Go's garbage collector optimizes memory usage
- Connection Pooling: Advanced connection reuse and management
- Zero Python Overhead: Direct C bindings bypass Python HTTP stack
�🛠️ Installation
Install from PyPI (Recommended)
pip install gorequests
Install from Source
git clone https://github.com/coffeecms/gorequests.git
cd gorequests
pip install -e .
Requirements
- Python 3.7+
- Windows, macOS, or Linux
- Pre-compiled Go library (included in package)
💡 Usage Examples
1. Basic HTTP Requests (Drop-in Replacement)
import gorequests as requests
# GET request
response = requests.get('https://api.github.com/users/octocat')
print(f"Status: {response.status_code}")
print(f"JSON: {response.json()}")
# POST with JSON
response = requests.post('https://httpbin.org/post',
json={'key': 'value', 'number': 42})
print(f"Response: {response.text}")
# Custom headers and parameters
response = requests.get('https://api.github.com/search/repositories',
params={'q': 'python', 'sort': 'stars'},
headers={'User-Agent': 'MyApp/1.0'})
2. Advanced Usage with Sessions
import gorequests
# Create a session for connection reuse
session = gorequests.Session()
# Login example
login_data = {'username': 'user', 'password': 'pass'}
session.post('https://example.com/login', json=login_data)
# Subsequent requests use the same session
profile = session.get('https://example.com/profile')
settings = session.get('https://example.com/settings')
# Session automatically handles cookies and authentication
3. Error Handling and Timeouts
import gorequests
from gorequests.exceptions import GoRequestsError, TimeoutError
try:
response = gorequests.get('https://api.example.com/data',
timeout=5, # 5 second timeout
headers={'Accept': 'application/json'})
if response.ok:
data = response.json()
print(f"Success: {data}")
else:
print(f"HTTP Error: {response.status_code}")
except TimeoutError:
print("Request timed out")
except GoRequestsError as e:
print(f"GoRequests error: {e}")
except Exception as e:
print(f"Unexpected error: {e}")
4. File Upload and Download
import gorequests
# File upload
with open('document.pdf', 'rb') as f:
files = {'file': ('document.pdf', f, 'application/pdf')}
response = gorequests.post('https://api.example.com/upload', files=files)
# Large file download with streaming
response = gorequests.get('https://example.com/largefile.zip', stream=True)
with open('downloaded_file.zip', 'wb') as f:
for chunk in response.iter_content(chunk_size=8192):
f.write(chunk)
# Multiple file upload
files = {
'file1': open('file1.txt', 'rb'),
'file2': open('file2.txt', 'rb')
}
response = gorequests.post('https://api.example.com/multi-upload', files=files)
5. Performance Monitoring and Statistics
import gorequests
import time
# Performance monitoring
start_time = time.time()
# Make multiple requests
responses = []
urls = ['https://httpbin.org/get'] * 10
for url in urls:
response = gorequests.get(url, params={'index': len(responses)})
responses.append(response.status_code)
elapsed = time.time() - start_time
print(f"10 requests completed in {elapsed:.2f}s")
print(f"Average: {elapsed/10:.3f}s per request")
# Memory statistics
stats = gorequests.get_memory_stats()
print(f"Memory usage: {stats['alloc']:,} bytes")
print(f"Active sessions: {stats['sessions']}")
print(f"Goroutines: {stats['goroutines']}")
# Performance comparison helper
def benchmark_comparison():
import requests as std_requests
# Standard requests timing
start = time.time()
std_requests.get('https://httpbin.org/get')
std_time = time.time() - start
# GoRequests timing
start = time.time()
gorequests.get('https://httpbin.org/get')
go_time = time.time() - start
improvement = (std_time / go_time) * 100
print(f"GoRequests is {improvement:.1f}% faster!")
🔧 Advanced Configuration
Custom Client Configuration
import gorequests
# Create client with custom settings
client = gorequests.GoRequestsClient(
dll_path="/custom/path/libgorequests.dll", # Custom library path
auto_setup=True # Auto-configure (default: True)
)
# Use custom client
response = client.get('https://api.example.com')
Environment Variables
# Optional: Custom library path
export GOREQUESTS_DLL_PATH="/path/to/libgorequests.dll"
# Optional: Enable debug mode
export GOREQUESTS_DEBUG=1
📈 Performance Optimization Tips
1. Use Sessions for Multiple Requests
# ❌ Slow: Creates new connection each time
for i in range(100):
gorequests.get(f'https://api.example.com/item/{i}')
# ✅ Fast: Reuses connections
session = gorequests.Session()
for i in range(100):
session.get(f'https://api.example.com/item/{i}')
2. Optimize Timeouts
# ✅ Set appropriate timeouts
response = gorequests.get('https://api.example.com',
timeout=5, # 5 second timeout
connect_timeout=2) # 2 second connect timeout
3. Use Streaming for Large Files
# ✅ Memory efficient for large downloads
response = gorequests.get('https://example.com/large-file.zip', stream=True)
🔍 Migration from Requests
GoRequests is designed as a drop-in replacement. Simply change your import:
# Before
import requests
response = requests.get('https://api.example.com')
# After - 5-10x faster!
import gorequests as requests
response = requests.get('https://api.example.com')
API Compatibility
- ✅
requests.get(),requests.post(), etc. - ✅
Session()class - ✅ Response objects (
response.json(),response.text, etc.) - ✅ Exception handling
- ✅ Timeouts and headers
- ✅ File uploads/downloads
- ✅ Authentication methods
🧪 Testing
# Run tests
python -m pytest tests/
# Run performance benchmarks
python examples/benchmark.py
# Run compatibility tests
python tests/test_compatibility.py
🤝 Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development Setup
git clone https://github.com/coffeecms/gorequests.git
cd gorequests
pip install -e ".[dev]"
python -m pytest
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Built with Go and FastHTTP
- Inspired by Python's requests library
- Thanks to the Go and Python communities
📞 Support
- GitHub Issues: https://github.com/coffeecms/gorequests/issues
- Documentation: https://gorequests.readthedocs.io
- PyPI: https://pypi.org/project/gorequests/
🔗 Links
- GitHub Repository: https://github.com/coffeecms/gorequests
- PyPI Package: https://pypi.org/project/gorequests/
- Documentation: https://gorequests.readthedocs.io
Made with ❤️ by the GoRequests Team
Transform your HTTP requests with the power of Go!
Metadata
Release files for gorequests 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gorequests-2.0.0.tar.gz | 4.3 MB | Without provenance | Details for gorequests-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gorequests-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for gorequests-2.0.0-py3-none-any.whl |
Total release size: 8.6 MB
Release files / gorequests-2.0.0.tar.gz
| Download URL | gorequests-2.0.0.tar.gz |
|---|---|
| Size | 4.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fe5daa824157d9757649c1043fb2f5b0b142e4c79f2553467c99104d66a8e9bc
|
|
BLAKE2b-256 checksum How to use checksums |
fb6cd0b578a0a669086dd80cc0e49693f2e7d8ad5a58a0099a5d0999f73be1c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.10
|
Release files / gorequests-2.0.0-py3-none-any.whl
| Download URL | gorequests-2.0.0-py3-none-any.whl |
|---|---|
| Size | 4.3 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6269ffa253bb197c2439dea132431bbe2b3d9fd0830ab4444506834d45a3430c
|
|
BLAKE2b-256 checksum How to use checksums |
ce38bb0c1b9a49714328d2328445ee0aef47004264d0825a2787056b7c511ff6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.10
|
Security for gorequests 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.