Skip to main content
This guide covers all installation methods and common setup issues.

Requirements

Python 3.9+

The SDK requires Python 3.9 or higher

pip or git

Install via pip or clone from source
Check your Python version:
python --version
# Should show 3.9.0 or higher

Install via pip

The simplest installation method:
pip install turbine-py-client
Verify the installation:
from turbine_client import TurbineClient
print("SDK installed successfully")

Install from source

For development or to use the latest features:
1

Clone the repository

git clone https://github.com/ojo-network/turbine-py-client.git
cd turbine-py-client
2

Create a virtual environment

python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
Always use a virtual environment to avoid dependency conflicts.
3

Install in editable mode

pip install -e .
This installs the SDK in “editable” mode, so changes to the source code are immediately reflected.

Install development dependencies

If you’re contributing to the SDK or running tests:
pip install -e ".[dev]"
This includes:
  • pytest — Test framework
  • pytest-asyncio — Async test support
  • mypy — Type checking
  • ruff — Linting and formatting
  • respx — HTTP mocking for tests

Dependencies

The SDK has minimal dependencies:
PackageVersionPurpose
eth-account≥0.13.0Ethereum wallet operations and EIP-712 signing
eth-utils≥4.1.1Ethereum utility functions
httpx[http2]≥0.27.0HTTP client with HTTP/2 support
websockets≥12.0WebSocket client for real-time updates
pynacl≥1.5.0Ed25519 signing for API authentication
python-dotenv≥1.0.0Environment variable management
All dependencies are automatically installed with the SDK.

Configuration

Environment variables

Create a .env file in your project root:
# Required for trading
TURBINE_PRIVATE_KEY=0x...  # Your wallet private key

# Auto-generated on first run (leave blank initially)
TURBINE_API_KEY_ID=
TURBINE_API_PRIVATE_KEY=

# Chain configuration
CHAIN_ID=137  # Polygon mainnet (recommended)

# API host
TURBINE_HOST=https://api.turbinefi.com

Load environment variables

In your Python code:
from dotenv import load_dotenv
import os

load_dotenv()  # Load .env file

private_key = os.environ.get("TURBINE_PRIVATE_KEY")
chain_id = int(os.environ.get("CHAIN_ID", "137"))

Chain configurations

The SDK supports three chains:

Getting a wallet

You need an Ethereum-compatible wallet private key:

Option 1: Export from MetaMask

  1. Install MetaMask browser extension
  2. Create or import an account
  3. Go to Settings → Security & Privacy
  4. Click Export Private Key
  5. Copy the private key (starts with 0x)

Option 2: Generate programmatically

from eth_account import Account

# Generate a new wallet
acct = Account.create()
print(f"Address: {acct.address}")
print(f"Private Key: {acct.key.hex()}")

# SAVE THESE! You'll need the private key to sign orders.
Security best practices:
  • Never commit your .env file to git
  • Use separate wallets for development and production
  • Store private keys securely (consider using a secrets manager for production)

Funding your wallet

You need USDC on Polygon to trade:
1

Get USDC on Polygon

Minimum: ~$10 USDC on Polygon mainnetOptions:
  • Bridge from Ethereum/other chains using Polygon Bridge
  • Withdraw directly from an exchange that supports Polygon (Coinbase, Binance, etc.)
  • Use a cross-chain swap service like Jumper
2

Verify your balance

from turbine_client import TurbineClient

client = TurbineClient(
    host="https://api.turbinefi.com",
    chain_id=137,
    private_key="0x...",
)

# Check USDC balance
balances = client.get_user_balances(client.address)
print(f"USDC: ${balances['usdc'] / 1e6:.2f}")
You do NOT need MATIC or any other gas tokens. Turbine is fully gasless — all operations are routed through the API.

Verifying installation

Test that everything works:
from turbine_client import TurbineClient

# Test public access (no auth)
client = TurbineClient(
    host="https://api.turbinefi.com",
    chain_id=137,
)

# Check API health
health = client.get_health()
print(f"API Status: {health}")

# Get markets
markets = client.get_markets()
print(f"Found {len(markets)} markets")

client.close()
print("✅ Installation verified")

Troubleshooting

Import errors

Problem: ModuleNotFoundError: No module named 'turbine_client' Solution:
# Make sure you're in the correct virtual environment
source .venv/bin/activate

# Reinstall the SDK
pip install --upgrade turbine-py-client

API credentials not generating

Problem: AuthenticationError: API credentials required Solution:
# Manually request credentials
from turbine_client import TurbineClient

credentials = TurbineClient.request_api_credentials(
    host="https://api.turbinefi.com",
    private_key="0x...",
)

print(f"API Key ID: {credentials['api_key_id']}")
print(f"API Private Key: {credentials['api_private_key']}")

# Add these to your .env file

Connection errors

Problem: httpx.ConnectError: Connection refused Solution:
  • Check your internet connection
  • Verify the API host is correct: https://api.turbinefi.com
  • Check if the API is operational: https://status.turbinefi.com

Python version errors

Problem: SyntaxError or type hint errors Solution:
# Check Python version (must be 3.9+)
python --version

# Upgrade Python if needed
# On Ubuntu/Debian:
sudo apt update && sudo apt install python3.11

# On macOS:
brew install [email protected]

Next steps

Quickstart

Place your first trade

API Reference

Explore all SDK methods

Trading bot guide

Build an automated trading strategy

WebSocket streaming

Real-time market data

Build docs developers (and LLMs) love