Documentation/Authentication

Authentication Guide

Secure API access for WebSocket and advanced features

Beginner15 minutes

Authentication Overview

AxiomTradeAPI supports two authentication modes:

Public API

No authentication required

  • Balance queries
  • Basic market data
  • WebSocket features
  • Real-time monitoring

Authenticated API

Requires auth tokens

  • All public features
  • WebSocket real-time data
  • Token launch monitoring
  • Advanced trading features

Method 1: Browser Developer Tools (Recommended)

Step-by-Step Guide

  1. 1

    Open Axiom Trade

    Visit https://axiom.trade and sign in to your account

  2. 2

    Open Developer Tools

    Press F12 or right-click → "Inspect"

  3. 3

    Navigate to Storage

    Go to the Application tab (Chrome) or Storage tab (Firefox)

  4. 4

    Find Cookies

    Expand Cookies → https://axiom.trade

    Look for these cookies:

    • • auth-access-token
    • • auth-refresh-token
  5. 5

    Copy Token Values

    Double-click the Value column and copy the entire token (starts with eyJ...)

Pro Tip

Tokens typically expire after 24 hours. The SDK automatically refreshes them using the refresh token, but you may need to update them occasionally.

Method 2: Network Tab Method

  1. 1

    Open Developer Tools

    Press F12 and go to the Network tab

  2. 2

    Sign In

    Log in to Axiom Trade while the Network tab is open

  3. 3

    Find Login Request

    Look for a request to /api/auth/login or similar

  4. 4

    View Response

    Click the request → Response tab to see the tokens in the JSON response

Configuring Your Bot

Create .env File
# .env file - KEEP THIS SECRET!
AXIOM_AUTH_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ...
AXIOM_REFRESH_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ...

# Add to .gitignore
# .env
# *.env
# .env.*
Python Configuration
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!")

Security Warning

  • • Never commit .env files to Git
  • • Never hardcode tokens directly in your code
  • • Rotate tokens regularly
  • • Use environment variables for production

Testing Authentication

test_auth.py
import 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())

Troubleshooting

"Authentication failed" Error

Solutions:

  • • Verify tokens are copied completely (including all characters)
  • • Check that tokens haven't expired (they typically last 24 hours)
  • • Ensure no extra spaces or line breaks in token values
  • • Re-obtain fresh tokens from Axiom Trade

".env file not found" Error

Solutions:

  • • Install python-dotenv: pip install python-dotenv
  • • Ensure .env file is in the same directory as your script
  • • Check file extension is exactly .env (not .env.txt)