Getting Started
Learn how to integrate and use OnionFleet in your projects.
Installation
To install OnionFleet, follow these steps:
git clone https://github.com/yourusername/onionfleet.git
cd onionfleet
pip install -r requirements.txt
python manage.py migrate
Configuration
Configure your OnionFleet instance by setting up the following environment variables:
# .env
DEBUG=False
SECRET_KEY=your-secret-key
DATABASE_URL=postgresql://user:password@localhost/dbname
ALLOWED_HOSTS=your-domain.com
Basic Usage
Start using OnionFleet by adding proxies to your pool:
from pool.models import Proxy
# Add a new proxy
proxy = Proxy.objects.create(
ip_address='192.168.1.1',
port=8080,
protocol='http'
)
# Get active proxies
active_proxies = Proxy.objects.filter(is_active=True)
Proxy Management
Understanding proxy health monitoring and maintenance.
Adding Proxies
You can add proxies manually or import them in bulk:
# Import proxies from a file
with open('proxies.txt', 'r') as f:
for line in f:
ip, port = line.strip().split(':')
Proxy.objects.create(
ip_address=ip,
port=int(port),
protocol='http'
)
Health Checks
OnionFleet regularly checks proxy health:
# Run health checks
from pool.utils import check_proxy_health
for proxy in Proxy.objects.all():
is_healthy = check_proxy_health(proxy)
if is_healthy:
proxy.mark_success()
else:
proxy.mark_failure()
Rotation Strategies
Implement different proxy rotation strategies:
# Get next proxy using round-robin
def get_next_proxy():
return Proxy.objects.filter(
is_active=True
).order_by('last_used').first()
API Reference
Complete API documentation for integrating with other services.
REST API
OnionFleet provides a RESTful API for integration:
# Example API endpoints
GET /api/proxies/ # List all proxies
POST /api/proxies/ # Add new proxy
GET /api/proxies/active/ # Get active proxies
PUT /api/proxies/{id}/ # Update proxy status
Python Client
Use the Python client for easy integration:
from onionfleet import Client
client = Client('your-api-key')
proxy = client.get_proxy()
response = client.request('https://example.com', proxy=proxy)
Authentication
Secure your OnionFleet instance:
# Generate API key
from pool.utils import generate_api_key
api_key = generate_api_key()
print(f"Your API key: {api_key}")