Documentation

API reference, SDK guides, and integration patterns for connecting algo trading bots to Alfax challenges.

OpenAPI SpecificationPython SDK Quickstartccxt / python-binance / FreqtradeHMAC-SHA256 AuthenticationAlfax Challenge Extensions

OpenAPI Specification

The complete Alfax API is documented in an OpenAPI 3.1 spec. All paths are byte-compatible with Binance Futures USDT-M.

View alfax-v1.yaml

Python SDK Quickstart

Install the first-party alfax package from PyPI for a typed, ergonomic client with challenge-aware helpers.

PyPI: alfax
pip install alfaxpython
pip install alfax

from alfax import Client

c = Client(
    api_key="YOUR_API_KEY",
    api_secret="YOUR_API_SECRET",
    base_url="https://api.alfax.trade",  # optional: defaults to api.alfax.trade
)

# Check challenge status
status = c.get_challenge_status()
print(status["currentEquity"], status["profitCurrent"])

# Place a market order
order = c.new_order(
    symbol="BTCUSDT",
    side="BUY",
    type="MARKET",
    quantity="0.001",
)

ccxt / python-binance / Freqtrade

Any library that supports Binance Futures works with a single base_url override. No code changes required.

ccxt drop-inpython
import ccxt

ex = ccxt.binanceusdm({
    "apiKey": "YOUR_KEY",
    "secret": "YOUR_SECRET",
    "urls": {
        "api": {
            "fapiPublic":    "https://api.alfax.trade/fapi",
            "fapiPrivate":   "https://api.alfax.trade/fapi",
            "fapiPrivateV2": "https://api.alfax.trade/fapi",
        }
    },
})

# Zero changes to your strategy needed
balance = ex.fetch_balance()
positions = ex.fetch_positions(["BTC/USDT:USDT"])

HMAC-SHA256 Authentication

Private endpoints require an X-MBX-APIKEY header and a signature query parameter — identical to Binance Futures auth.

Manual signing (Python)python
import hashlib, hmac, time, urllib.parse

def sign(params: dict, secret: str) -> str:
    qs = urllib.parse.urlencode(params)
    return hmac.new(
        secret.encode(), qs.encode(), hashlib.sha256
    ).hexdigest()

params = {
    "symbol": "BTCUSDT",
    "timestamp": int(time.time() * 1000),
}
params["signature"] = sign(params, "YOUR_SECRET")

# Include X-MBX-APIKEY: YOUR_KEY header in every request

Alfax Challenge Extensions

Two non-Binance endpoints provide challenge-specific data: GET /fapi/v1/challenge and GET /fapi/v1/challenge/rules. The user-data WebSocket stream also emits challengeUpdate events.

Challenge status endpoint Challenge rules endpoint

The Alfax API is under active development. For questions, open an issue on the GitHub repository. Contract gaps or spec discrepancies should be flagged there, not worked around.