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
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
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/sol-balanceGet SOL balance for a wallet address
GetBalance(), get_sol_balance()
ENDPOINT_GET_BATCHED_BALANCE/batched-sol-balanceGet SOL balances for multiple wallets
Internal batched operations
ENDPOINT_BUY_TOKEN/buyPurchase tokens using SOL
buy_token() (legacy)
ENDPOINT_SELL_TOKEN/sellSell tokens for SOL
sell_token() (legacy)
ENDPOINT_SEND_TRANSACTION/send-transactionSubmit signed transactions to blockchain
send_transaction_to_rpc()
ENDPOINT_GET_TOKEN_BALANCE/token-balanceGet balance of specific SPL tokens
get_token_balance()
Basic Usage Examples
Example 1: View All Endpoints
Display all available endpoints and their values.
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.
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.
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 GitHubBest Practices
1. Don't Hardcode URLs
# ā 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
# ā
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
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 client4. Document Endpoint Usage
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 requestEndpoint Reference Table
| Constant | Path | Purpose | Auth |
|---|---|---|---|
ENDPOINT_GET_BALANCE | /sol-balance | Get SOL balance | |
ENDPOINT_GET_BATCHED_BALANCE | /batched-sol-balance | Get multiple balances | |
ENDPOINT_BUY_TOKEN | /buy | Buy tokens | |
ENDPOINT_SELL_TOKEN | /sell | Sell tokens | |
ENDPOINT_SEND_TRANSACTION | /send-transaction | Send transaction | |
ENDPOINT_GET_TOKEN_BALANCE | /token-balance | Get token balance |
Related Documentation
Build Robust API Integrations
Need help implementing endpoint management and monitoring? Our team can assist you.