Secure API access for WebSocket and advanced features
AxiomTradeAPI supports two authentication modes:
No authentication required
Requires auth tokens
Open Axiom Trade
Visit https://axiom.trade and sign in to your account
Open Developer Tools
Press F12 or right-click → "Inspect"
Navigate to Storage
Go to the Application tab (Chrome) or Storage tab (Firefox)
Find Cookies
Expand Cookies → https://axiom.trade
Look for these cookies:
auth-access-tokenauth-refresh-tokenCopy Token Values
Double-click the Value column and copy the entire token (starts with eyJ...)
Tokens typically expire after 24 hours. The SDK automatically refreshes them using the refresh token, but you may need to update them occasionally.
Open Developer Tools
Press F12 and go to the Network tab
Sign In
Log in to Axiom Trade while the Network tab is open
Find Login Request
Look for a request to /api/auth/login or similar
View Response
Click the request → Response tab to see the tokens in the JSON response
# .env file - KEEP THIS SECRET!
AXIOM_AUTH_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ...
AXIOM_REFRESH_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ...
# Add to .gitignore
# .env
# *.env
# .env.*import os
from dotenv import load_dotenv
from axiomtradeapi import AxiomTradeClient
# Load environment variables
load_dotenv()
# Initialize authenticated client
client = AxiomTradeClient(
auth_token=os.getenv('AXIOM_AUTH_TOKEN'),
refresh_token=os.getenv('AXIOM_REFRESH_TOKEN')
)
print("✅ Authenticated client ready!").env files to Gitimport os
import asyncio
from dotenv import load_dotenv
from axiomtradeapi import AxiomTradeClient
load_dotenv()
async def test_authentication():
"""Test if authentication is working"""
# Initialize client
client = AxiomTradeClient(
auth_token=os.getenv('AXIOM_AUTH_TOKEN'),
refresh_token=os.getenv('AXIOM_REFRESH_TOKEN')
)
print("🔐 Testing authentication...")
# Test WebSocket connection (requires auth)
async def handle_tokens(tokens):
print(f"✅ Authentication successful!")
print(f"📡 Received {len(tokens)} tokens")
return True # Stop after first batch
try:
await asyncio.wait_for(
client.subscribe_new_tokens(callback=handle_tokens),
timeout=10.0
)
except asyncio.TimeoutError:
print("⏱️ Test completed (timeout)")
except Exception as e:
print(f"❌ Authentication failed: {e}")
if __name__ == "__main__":
asyncio.run(test_authentication())Solutions:
Solutions:
pip install python-dotenv.env file is in the same directory as your script.env (not .env.txt)