endpoints Attribute

Centralized API endpoint URL configuration and management

Base URLs
Root API URLs
Endpoint Paths
API routes
Configuration
Single source
Type Safety
No typos

Overview

The endpoints attribute is an instance of the Endpoints class that centralizes all API endpoint URLs and base URLs used by the AxiomTradeClient. This provides a single source of truth for API endpoint configuration, making it easy to access, modify, or verify the URLs used for various API operations.

What is endpoints?

The endpoints attribute stores base URLs (root API URLs for different services) and endpoint paths (specific API endpoint paths for various operations).

URL Construction

Build API request URLs programmatically

Configuration

Centralized endpoint management

Testing

Override for different environments

Monitoring

Track endpoint usage and health

Class Definition

python
from axiomtradeapi.content.endpoints import Endpoints

class Endpoints:
    # Base URLs
    BASE_URL_API = "https://axiom.trade/api"
    BASE_URL = "https://axiom.trade"
    
    # Endpoint Paths
    ENDPOINT_GET_BALANCE = "/sol-balance"
    ENDPOINT_GET_BATCHED_BALANCE = "/batched-sol-balance"
    ENDPOINT_BUY_TOKEN = "/buy"
    ENDPOINT_SELL_TOKEN = "/sell"
    ENDPOINT_SEND_TRANSACTION = "/send-transaction"
    ENDPOINT_GET_TOKEN_BALANCE = "/token-balance"

Accessing endpoints

python
from axiomtradeapi import AxiomTradeClient

client = AxiomTradeClient()

# Access the endpoints object
endpoints = client.endpoints

# Access base URLs
print(endpoints.BASE_URL_API)  # "https://axiom.trade/api"
print(endpoints.BASE_URL)      # "https://axiom.trade"

# Access endpoint paths
print(endpoints.ENDPOINT_GET_BALANCE)  # "/sol-balance"
print(endpoints.ENDPOINT_BUY_TOKEN)    # "/buy"

Available Base URLs

BASE_URL_API

"https://axiom.trade/api"
  • Purpose: Primary API base URL for most operations
  • Used For: Trading operations, balance queries, transactions
  • Example: https://axiom.trade/api/sol-balance

BASE_URL

"https://axiom.trade"
  • Purpose: Main website base URL
  • Used For: Web-related operations, authentication redirects
  • Example: https://axiom.trade

Available Endpoint Paths

ENDPOINT_GET_BALANCE
Path: /sol-balance
GET
Purpose:

Get SOL balance for a wallet address

Used By:

GetBalance(), get_sol_balance()

ENDPOINT_GET_BATCHED_BALANCE
Path: /batched-sol-balance
POST
Purpose:

Get SOL balances for multiple wallets

Used By:

Internal batched operations

ENDPOINT_BUY_TOKEN
Path: /buy
POST
Purpose:

Purchase tokens using SOL

Used By:

buy_token() (legacy)

ENDPOINT_SELL_TOKEN
Path: /sell
POST
Purpose:

Sell tokens for SOL

Used By:

sell_token() (legacy)

ENDPOINT_SEND_TRANSACTION
Path: /send-transaction
POST
Purpose:

Submit signed transactions to blockchain

Used By:

send_transaction_to_rpc()

ENDPOINT_GET_TOKEN_BALANCE
Path: /token-balance
GET
Purpose:

Get balance of specific SPL tokens

Used By:

get_token_balance()

Basic Usage Examples

Example 1: View All Endpoints

Display all available endpoints and their values.

python
from axiomtradeapi import AxiomTradeClient

client = AxiomTradeClient()

print("šŸ“‹ Axiom Trade API Endpoints")
print("=" * 50)

# Base URLs
print("\n🌐 Base URLs:")
print(f"  API Base:  {client.endpoints.BASE_URL_API}")
print(f"  Web Base:  {client.endpoints.BASE_URL}")

# Endpoint paths
print("\nšŸ”— Endpoint Paths:")
print(f"  Balance:          {client.endpoints.ENDPOINT_GET_BALANCE}")
print(f"  Buy Token:        {client.endpoints.ENDPOINT_BUY_TOKEN}")
print(f"  Sell Token:       {client.endpoints.ENDPOINT_SELL_TOKEN}")

# Construct full URLs
print("\nšŸ”— Full URLs:")
print(f"  Balance:  {client.endpoints.BASE_URL_API}{client.endpoints.ENDPOINT_GET_BALANCE}")

Example 2: Build Custom API URLs

Use endpoints to construct API URLs programmatically.

python
from axiomtradeapi import AxiomTradeClient

client = AxiomTradeClient()

def build_api_url(endpoint_path: str) -> str:
    """Build full API URL from endpoint path"""
    return f"{client.endpoints.BASE_URL_API}{endpoint_path}"

# Build URLs for different endpoints
balance_url = build_api_url(client.endpoints.ENDPOINT_GET_BALANCE)
token_balance_url = build_api_url(client.endpoints.ENDPOINT_GET_TOKEN_BALANCE)

print(f"Balance URL: {balance_url}")
print(f"Token Balance URL: {token_balance_url}")

Example 3: Verify Endpoint Configuration

Check that endpoints are correctly configured before using the client.

python
from axiomtradeapi import AxiomTradeClient

def verify_endpoints(client: AxiomTradeClient) -> bool:
    """Verify all endpoints are properly configured"""
    print("šŸ” Verifying endpoint configuration...")
    
    endpoints = client.endpoints
    issues = []
    
    # Check base URLs use HTTPS
    if not endpoints.BASE_URL_API.startswith("https://"):
        issues.append("BASE_URL_API doesn't use HTTPS")
    
    # Check endpoint paths start with /
    if not endpoints.ENDPOINT_GET_BALANCE.startswith("/"):
        issues.append("Endpoint paths must start with /")
    
    if issues:
        print("āŒ Issues found:")
        for issue in issues:
            print(f"   - {issue}")
        return False
    
    print("āœ… All endpoints configured correctly")
    return True

client = AxiomTradeClient()
verify_endpoints(client)

Advanced Examples

Advanced usage patterns for production applications:

Endpoint Health Check

Monitor endpoint availability

Custom Endpoint Override

Use test/staging environments

Endpoint Usage Logger

Track API usage statistics

Configuration Validator

Validate before deployment

Full advanced examples with complete code are available in the GitHub repository

View Examples on GitHub

Best Practices

1. Don't Hardcode URLs

python
# āŒ Bad: Hardcoded URL
url = "https://axiom.trade/api/sol-balance"

# āœ… Good: Use endpoints
url = f"{client.endpoints.BASE_URL_API}{client.endpoints.ENDPOINT_GET_BALANCE}"

2. Reference Endpoints Consistently

python
# āœ… Good: Consistent reference
def get_balance_url(client):
    return f"{client.endpoints.BASE_URL_API}{client.endpoints.ENDPOINT_GET_BALANCE}"

# Always use this function
url = get_balance_url(client)

3. Validate Configuration on Startup

python
def initialize_client():
    """Initialize client with validation"""
    client = AxiomTradeClient()
    
    # Verify endpoints are configured
    assert client.endpoints.BASE_URL_API.startswith("https://")
    assert client.endpoints.ENDPOINT_GET_BALANCE.startswith("/")
    
    return client

4. Document Endpoint Usage

python
def fetch_balance():
    """
    Fetch SOL balance
    
    Endpoint: /sol-balance
    Full URL: https://axiom.trade/api/sol-balance
    """
    url = f"{client.endpoints.BASE_URL_API}{client.endpoints.ENDPOINT_GET_BALANCE}"
    # ... make request

Endpoint Reference Table

ConstantPathPurposeAuth
ENDPOINT_GET_BALANCE/sol-balanceGet SOL balance
ENDPOINT_GET_BATCHED_BALANCE/batched-sol-balanceGet multiple balances
ENDPOINT_BUY_TOKEN/buyBuy tokens
ENDPOINT_SELL_TOKEN/sellSell tokens
ENDPOINT_SEND_TRANSACTION/send-transactionSend transaction
ENDPOINT_GET_TOKEN_BALANCE/token-balanceGet token balance

Related Documentation

Build Robust API Integrations

Need help implementing endpoint management and monitoring? Our team can assist you.

Open Source

Contribute to AxiomTradeAPI

View on GitHub

Community

Join 1000+ developers

Join Discord

Custom Development

Professional bot building

Get Started