FoxCalc
API Integration

Authentication

API Key + HMAC signature authentication for the FoxCalc API

All funder API requests use API Key + HMAC-SHA256 signature authentication. This provides request-level integrity verification without token refresh complexity.

Required Headers

Every request must include three headers:

HeaderDescription
X-API-KeyYour API key (identifies your funder account)
X-TimestampUnix timestamp in seconds (replay protection)
X-SignatureHMAC-SHA256 signature of the request

Computing the Signature

The signature is computed over the concatenation of the timestamp and request body:

message = timestamp + "." + request_body
signature = HMAC-SHA256(message, your_hmac_secret)

Node.js Example

import crypto from 'crypto';

function signRequest(body, hmacSecret) {
  const timestamp = Math.floor(Date.now() / 1000).toString();
  const message = `${timestamp}.${JSON.stringify(body)}`;
  const signature = crypto
    .createHmac('sha256', hmacSecret)
    .update(message)
    .digest('hex');

  return {
    'X-Timestamp': timestamp,
    'X-Signature': signature,
  };
}

Python Example

import hmac
import hashlib
import json
import time

def sign_request(body: dict, hmac_secret: str) -> dict:
    timestamp = str(int(time.time()))
    message = f"{timestamp}.{json.dumps(body, separators=(',', ':'))}"
    signature = hmac.new(
        hmac_secret.encode(),
        message.encode(),
        hashlib.sha256
    ).hexdigest()

    return {
        "X-Timestamp": timestamp,
        "X-Signature": signature,
    }

Replay Protection

Requests with timestamps older than 5 minutes are rejected. Ensure your server's clock is synchronized (NTP).

API Key Scopes

API keys are issued with specific scopes:

ScopeDescription
offers:createCreate new offers
offers:updateReplace or patch existing offers
offers:deleteRevoke offers

Error Responses

StatusError CodeDescription
401UNAUTHORIZEDMissing or invalid API key
401SIGNATURE_INVALIDHMAC signature verification failed
401TIMESTAMP_EXPIREDTimestamp older than 5 minutes
403INSUFFICIENT_SCOPEAPI key lacks required scope
429RATE_LIMITEDToo many requests