SDK
Python SDK
Installation

Installation

Requirements

  • Python: 3.11 or higher
  • Package Manager: pip or poetry

Install via pip

pip install sniperoute

Install via poetry

poetry add sniperoute

Install from Source

git clone https://github.com/alibrahim/sniperoute-sdk-python.git
cd sniperoute-sdk-python
pip install -e .

Verify Installation

import sniperoute
 
print(sniperoute.__version__)  # Should print version number

Dependencies

The SDK automatically installs these dependencies:

PackageVersionPurpose
httpx>= 0.26.0Async HTTP client
pydantic>= 2.5.0Data validation and serialization
python-dotenv>= 1.0.0Environment variable management

Optional Dependencies

Development

For development and testing:

pip install sniperoute[dev]

Includes:

  • pytest - Testing framework
  • pytest-cov - Coverage reporting
  • pytest-asyncio - Async test support
  • mypy - Type checking
  • ruff - Linting and formatting

Type Checking

For type stubs:

pip install sniperoute[types]

Environment Setup

1. Create .env File

touch .env

2. Add Credentials

# .env
SNIPEROUTE_API_KEY=sk_live_your_api_key_here
SNIPEROUTE_API_URL=https://api.sniperoute.io

3. Load Environment Variables

The SDK automatically loads .env files using python-dotenv:

from sniperoute import SnipeRouteClient
 
# Automatically uses SNIPEROUTE_API_KEY and SNIPEROUTE_API_URL
client = SnipeRouteClient()
⚠️

Never commit .env files to version control. Add .env to your .gitignore.

Virtual Environment Setup

Using venv

# Create virtual environment
python -m venv venv
 
# Activate (Linux/macOS)
source venv/bin/activate
 
# Activate (Windows)
venv\Scripts\activate
 
# Install SDK
pip install sniperoute

Using poetry

# Create project
poetry new my-trading-app
cd my-trading-app
 
# Add SDK
poetry add sniperoute
 
# Activate shell
poetry shell

IDE Setup

VS Code

Install Python extension and add to .vscode/settings.json:

{
  "python.linting.enabled": true,
  "python.linting.mypyEnabled": true,
  "python.formatting.provider": "black"
}

PyCharm

  1. Go to Settings → Project → Python Interpreter
  2. Add sniperoute package
  3. Enable Type Checking in settings

Troubleshooting

ModuleNotFoundError: No module named 'sniperoute'

Problem: SDK not installed in current environment

Solution:

# Verify you're in correct virtual environment
which python
 
# Reinstall SDK
pip install sniperoute
ImportError: cannot import name 'SnipeRouteClient'

Problem: Outdated SDK version

Solution:

# Upgrade to latest version
pip install --upgrade sniperoute
TypeError: 'Decimal' object is not iterable

Problem: Missing decimal import

Solution:

from decimal import Decimal
 
quantity = Decimal("10")  # Not: 10
httpx.ConnectError: Connection refused

Problem: Invalid API URL

Solution:

# Check .env file
SNIPEROUTE_API_URL=https://api.sniperoute.io  # Correct

Upgrade

Upgrade to Latest Version

pip install --upgrade sniperoute

Upgrade to Specific Version

pip install sniperoute==1.2.0

Check Current Version

import sniperoute
print(sniperoute.__version__)

Uninstall

pip uninstall sniperoute

Next Steps