base_headers

Standard HTTP headers for browser emulation and API compatibility

Browser Emulation
Real browser headers
CORS Compliant
Cross-origin ready
Customizable
Add your headers
Dictionary Type
Dict[str, str]

Overview

The base_headers attribute is a dictionary containing standard HTTP headers used for all API requests to Axiom Trade. These headers ensure proper communication with the API and help requests appear as legitimate browser traffic.

Browser Emulation

Makes requests look like they come from a real browser

CORS Compliance

Ensures proper Cross-Origin Resource Sharing

Content Negotiation

Specifies accepted response formats

Request Context

Provides necessary metadata for the API

Type Definition

python
base_headers: Dict[str, str]

Default Structure

python
{
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36',
    'Accept': 'application/json, text/plain, */*',
    'Accept-Language': 'en-US,en;q=0.9',
    'Accept-Encoding': 'gzip, deflate, br',
    'Origin': 'https://axiom.trade',
    'Connection': 'keep-alive',
    'Referer': 'https://axiom.trade/',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'same-site'
}

Header Flow Diagram

┌─────────────────────────────────────────────────────┐
│ base_headers │
├─────────────────────────────────────────────────────┤
│ │
│ User-Agent ──────────► Browser identification │
│ Accept ──────────────► Accepted content types │
│ Accept-Language ─────► Preferred languages │
│ Accept-Encoding ─────► Supported compression │
│ Origin ──────────────► Request origin (CORS) │
│ Connection ──────────► Connection persistence │
│ Referer ─────────────► Previous page URL │
│ sec-fetch-* ─────────► Fetch metadata (security) │
│ │
└─────────────────────────────────────────────────────┘

Headers Explained

User-Agent

python
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36'

Purpose: Identifies the client making the request

Why Important:

  • • API servers often check User-Agent to block bots
  • • Emulates a real Chrome browser on Windows 10
  • • Helps requests pass anti-bot measures

Accept

python
'Accept': 'application/json, text/plain, */*'

Purpose: Tells server what content types the client can handle

application/json

Primary: JSON responses

text/plain

Secondary: Plain text

*/*

Fallback: Any type

Accept-Language

python
'Accept-Language': 'en-US,en;q=0.9'

Purpose: Specifies preferred language(s)

en-US

American English (priority 1.0)

en;q=0.9

Generic English (priority 0.9)

Accept-Encoding

python
'Accept-Encoding': 'gzip, deflate, br'

Purpose: Indicates supported compression algorithms

gzip

Standard compression

deflate

Alternative compression

br

Brotli (modern)

CORS Headers

python
'Origin': 'https://axiom.trade'
'Referer': 'https://axiom.trade/'

Purpose: Required for cross-origin API requests

  • Origin: Indicates request origin for CORS
  • Referer: URL of the page that initiated the request

Security Headers (sec-fetch-*)

python
'sec-fetch-dest': 'empty'
'sec-fetch-mode': 'cors'
'sec-fetch-site': 'same-site'

Purpose: Modern security metadata

sec-fetch-dest: empty - Not requesting a specific resource type
sec-fetch-mode: cors - Cross-origin request
sec-fetch-site: same-site - Same site request

Basic Usage

Example 1: Viewing Base Headers

python
from axiomtradeapi import AxiomTradeClient

# Initialize client
client = AxiomTradeClient()

# View all base headers
print("📋 Base Headers:")
print("=" * 60)
for key, value in client.base_headers.items():
    print(f"{key:20} : {value[:50]}...")

Example 2: Check Specific Header

python
from axiomtradeapi import AxiomTradeClient

client = AxiomTradeClient()

# Get specific header
user_agent = client.base_headers.get('User-Agent')
accept = client.base_headers.get('Accept')

print(f"User-Agent: {user_agent}")
print(f"Accept: {accept}")

Example 3: Headers Are Automatically Used

python
from axiomtradeapi import AxiomTradeClient

client = AxiomTradeClient()
client.login("email@example.com", "password")

# All API calls automatically use base_headers
# You don't need to do anything special!
balance = client.GetBalance("wallet_address")

# Behind the scenes, the client uses base_headers
# combined with authentication headers

Automatic Usage

You don't need to manually include base_headers in your API calls. The AxiomTradeClient automatically includes them in every request!

Customization

Adding Custom Headers

python
from axiomtradeapi import AxiomTradeClient

client = AxiomTradeClient()

# Add a custom header
client.base_headers['X-Custom-Header'] = 'MyValue'

# Add multiple custom headers
client.base_headers.update({
    'X-Api-Version': '1.0',
    'X-Client-ID': 'my-trading-bot',
    'X-Request-ID': '12345'
})

print("Updated headers:")
for key, value in client.base_headers.items():
    print(f"  {key}: {value}")

Modifying Existing Headers

python
from axiomtradeapi import AxiomTradeClient

client = AxiomTradeClient()

# Change User-Agent
client.base_headers['User-Agent'] = 'MyCustomBot/1.0'

# Change Accept
client.base_headers['Accept'] = 'application/json'

# Change language preference
client.base_headers['Accept-Language'] = 'es-ES,es;q=0.9'

print("Modified headers:")
print(f"User-Agent: {client.base_headers['User-Agent']}")
print(f"Accept-Language: {client.base_headers['Accept-Language']}")

Caution

Modifying default headers may cause API requests to fail. Only modify headers if you understand their purpose.

Creating Custom Header Profiles

python
from axiomtradeapi import AxiomTradeClient

class CustomHeaderProfiles:
    """Predefined header profiles for different scenarios"""
    
    @staticmethod
    def chrome_windows():
        """Chrome on Windows"""
        return {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36',
            'Accept': 'application/json, text/plain, */*',
            'Accept-Language': 'en-US,en;q=0.9',
            'Accept-Encoding': 'gzip, deflate, br',
            'Origin': 'https://axiom.trade',
            'Connection': 'keep-alive',
            'Referer': 'https://axiom.trade/'
        }
    
    @staticmethod
    def firefox_linux():
        """Firefox on Linux"""
        return {
            'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0',
            'Accept': 'application/json, text/plain, */*',
            'Accept-Language': 'en-US,en;q=0.5',
            'Accept-Encoding': 'gzip, deflate, br',
            'Origin': 'https://axiom.trade',
            'Connection': 'keep-alive',
            'Referer': 'https://axiom.trade/'
        }

# Usage
client = AxiomTradeClient()

# Apply Firefox profile
client.base_headers = CustomHeaderProfiles.firefox_linux()
print(f"Using Firefox profile: {client.base_headers['User-Agent']}")

Best Practices

DO

  • Keep default headers - they're optimized
  • Add headers with .update() method
  • Copy headers before modifying for custom requests
  • Validate headers after modifications
  • Use environment-specific User-Agents if needed
  • Keep security headers (sec-fetch-*) intact

DON'T

  • Remove required headers (User-Agent, Origin, etc.)
  • Replace all headers - add to existing instead
  • Use invalid or malformed header values
  • Expose sensitive data in custom headers
  • Log full headers in production (may contain auth)
  • Hardcode User-Agent strings for testing

Recommended Pattern

python
from axiomtradeapi import AxiomTradeClient

client = AxiomTradeClient()

# ✅ GOOD - Add to existing headers
client.base_headers.update({
    'X-Custom-Header': 'value'
})

# ❌ BAD - Replace all headers
# client.base_headers = {'User-Agent': 'MyBot'}  # Missing required headers!

# ✅ GOOD - Copy before modifying
custom_headers = client.base_headers.copy()
custom_headers['X-Custom'] = 'value'

# Use custom_headers for special requests
# Original base_headers unchanged

Common Issues

Issue: "403 Forbidden" Errors

Cause: Missing or invalid headers

Solution:

python
from axiomtradeapi import AxiomTradeClient

client = AxiomTradeClient()

# Verify all required headers are present
required = ['User-Agent', 'Origin', 'Referer']
missing = [h for h in required if h not in client.base_headers]

if missing:
    print(f"❌ Missing headers: {missing}")
    # Restore defaults
    client = AxiomTradeClient()  # Recreate client
else:
    print("✅ All required headers present")

Issue: Modified Headers Causing Failures

Cause: Accidentally modified critical headers

Solution:

python
from axiomtradeapi import AxiomTradeClient

# Save original headers
client = AxiomTradeClient()
original_headers = client.base_headers.copy()

# If something goes wrong, restore
def restore_headers():
    client.base_headers = original_headers.copy()
    print("✅ Headers restored to defaults")

# Test after modifications
try:
    balance = client.GetBalance("wallet")
except Exception as e:
    print(f"❌ Error: {e}")
    restore_headers()

Issue: Headers Not Applied to Requests

Cause: Using wrong method to make requests

Solution:

python
from axiomtradeapi import AxiomTradeClient
import requests

client = AxiomTradeClient()

# ✅ CORRECT - Use client methods (headers applied automatically)
balance = client.GetBalance("wallet")

# ❌ WRONG - Direct requests won't use client headers
# response = requests.get("https://axiom.trade/api/endpoint")  # No headers!

# ✅ CORRECT - If making custom requests, use base_headers
headers = client.base_headers.copy()
response = requests.get("https://axiom.trade/api/endpoint", headers=headers)

Still Having Issues?

Our support team can help you debug header-related problems

Related Documentation

Build Professional Trading Bots

Need help optimizing HTTP headers or API integration? We offer custom development services.

Open Source

Contribute to AxiomTradeAPI

View on GitHub

Community

Join 1000+ developers

Join Discord

Custom Development

Professional bot building

Get Started