Overview

The Tradecraft API provides programmatic access to real-time token analytics on the Solana blockchain. It returns technical indicators (EMA, RSI, MACD, Fibonacci, buy/sell pressure) for any token tracked by the platform.

Base URL
https://api.tradecraft.finance/v1

Unlike traditional APIs, Tradecraft uses the x402 payment protocol for authentication. Instead of API keys, you pay per request using TRADECRAFT tokens on Solana. For high-volume usage, you can pre-purchase credit bundles at a discount.

Payment Token

TRADECRAFT H5FHcnP1MaAet83QJC8KaS5H8bJfUM3kYsWy7nCgBAGS on Solana mainnet. Prices are ~$0.0025 USD per request, dynamically converted to TRADECRAFT at the current market rate.

Authentication

There are two ways to authenticate requests:

Option A: Per-request x402 Payment

  1. Send your request without any payment headers
  2. Receive HTTP 402 Payment Required with payment details in the PAYMENT-REQUIRED header
  3. Build and sign a Solana transaction paying the required TRADECRAFT tokens
  4. Retry the request with the PAYMENT-SIGNATURE header
  5. Server settles the transaction on-chain and returns the data

Best for: programmatic clients using the @x402/core SDK

Option B: Pre-purchased Credit Token

  1. Purchase a credit bundle via POST /v1/credits/purchase
  2. Receive a credit token: tc_credit_<64 hex chars>
  3. Include it as a Bearer token on subsequent requests:
Authorization: Bearer tc_credit_<your_token>

Best for: high-volume usage, simpler integration (no Solana signing per request)

Rate Limits

LimitRateScope
Public endpoints30 requests / minuteToken data, credits

When rate-limited, the API returns HTTP 429 Too Many Requests. Wait before retrying.

Response Format

All responses follow a consistent JSON structure:

Success Response
{
  "success": true,
  "data": { ... },
  "meta": {
    "timestamp": "2025-01-15T10:30:00.000Z",
    "requestId": "req_abc123"
  }
}
Error Response
{
  "success": false,
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable description"
  },
  "meta": {
    "timestamp": "2025-01-15T10:30:00.000Z",
    "requestId": "req_abc123"
  }
}

Get Token Data

GET
/v1/token/:tokenAddress

Returns current price, technical indicators, and buy/sell pressure data for any Solana token tracked by the platform.

Parameters

NameTypeDescription
tokenAddressstring (path)Solana token mint address (base58, 32-44 chars)

Pricing

~$0.0025 USD per request, paid in TRADECRAFT tokens at the current market rate. Use a credit token to avoid per-request on-chain payment.

Request (with credit token)
curl -X GET "https://api.tradecraft.finance/v1/token/So11111111111111111111111111111111111111112" \
  -H "Authorization: Bearer tc_credit_<your_token>"
Request (with x402 payment)
curl -X GET "https://api.tradecraft.finance/v1/token/So11111111111111111111111111111111111111112" \
  -H "PAYMENT-SIGNATURE: <signed_payment>"
Response (200)
{
  "success": true,
  "data": {
    "token": "So11111111111111111111111111111111111111112",
    "price": {
      "usd": 148.52,
      "sol": 1.0
    },
    "indicators": {
      "m1": {
        "ema9": 0.000232,
        "ema21": 0.000222,
        "ema50": 0.000202,
        "ema200": 0.000169,
        "rsi": 66.20,
        "macd": { "line": 0.000012, "signal": 0.000013, "histogram": -0.0000008 },
        "fibonacci": {
          "swingHigh": 0.000251, "swingLow": 0.000197,
          "level236": 0.000238, "level382": 0.000230,
          "level500": 0.000224, "level618": 0.000217, "level764": 0.000209,
          "ext1272": 0.000265, "ext1618": 0.000284,
          "ext2000": 0.000305, "ext2618": 0.000338
        }
      },
      "m5": { "ema9": 0.000200, "ema21": 0.000182, "..." : "..." },
      "m15": { "ema9": 0.000173, "ema200": null, "..." : "..." },
      "h1": { "ema9": 0.000149, "ema50": null, "ema200": null, "rsi": null, "macd": null, "..." : "..." },
      "buySellPressure": {
        "m1": 0, "m5": 0.482, "m15": 0.394,
        "h1": 0.394, "h4": 0.508, "d1": 0.497
      }
    },
    "dataSpan": {
      "from": 1706000000000,
      "to": 1706800000000,
      "candleCounts": { "m1": 4320, "m5": 1440, "m15": 480, "h1": 120 }
    }
  },
  "meta": {
    "timestamp": "2025-01-15T10:30:00.000Z",
    "requestId": "req_abc123"
  }
}

Error Codes

CodeStatusDescription
INVALID_TOKEN_ADDRESS400Not a valid Solana base58 address
TOKEN_NOT_FOUND404Token not tracked by the platform
INSUFFICIENT_DATA404Not enough price history for indicators

Available Indicators

Indicators are computed across multiple timeframes. Values may be null for tokens with insufficient price history.

IndicatorTimeframesDescription
EMA (9, 21, 50, 200)m1, m5, m15, h1Exponential Moving Averages — smoothed price trend lines. Price above EMA = bullish, below = bearish. Shorter periods (9, 21) react faster; longer periods (50, 200) show broader trend direction.
RSI (14)m1, m5, m15, h1Relative Strength Index — momentum oscillator from 0 to 100. Above 70 = overbought (potential reversal down), below 30 = oversold (potential reversal up), around 50 = neutral.
MACD (12, 26, 9)m1, m5, m15, h1Moving Average Convergence Divergence — trend and momentum indicator. Returns line, signal, and histogram. Positive histogram = bullish momentum, negative = bearish. When line crosses above signal = bullish crossover; below = bearish. Null when insufficient candle data.
Fibonaccim1, m5, m15, h1Fibonacci retracement and extension levels calculated from the recent swing high/low. Retracements (23.6%, 38.2%, 50%, 61.8%, 76.4%) indicate potential support/resistance during pullbacks. Extensions (127.2%, 161.8%, 200%, 261.8%) project potential price targets beyond the swing high. Also returns the swingHigh and swingLow used for the calculation.
Buy/Sell Pressurem1, m5, m15, h1, h4, d1Ratio of buy volume to total volume, from 0 to 1. A value of 0 means no buy volume was recorded in that timeframe (all sells or no trades). Above 0.5 = more buying pressure, below 0.5 = more selling pressure. Computed from on-chain swap data across multiple timeframes.

Note: EMA-200 requires ~200 candles of data for the given timeframe before returning values. Newer or low-volume tokens may only have partial indicator coverage.

Credit System

Credits let you pre-pay for API requests in bulk at a discount. Instead of signing an on-chain transaction per request, you use a credit token as a Bearer header. One credit is consumed per request.

Volume Discounts

Up to 40% off with larger bundles

No Expiry

Credits remain valid until used

No On-Chain Overhead

Skip Solana signing on every request

Atomic Consumption

Credits are deducted atomically per request

List Credit Bundles

GET
/v1/credits/bundles

Returns available credit bundles with prices in TRADECRAFT tokens at the current market rate. No payment or authentication required.

Request
curl -X GET "https://api.tradecraft.finance/v1/credits/bundles"
Response (200)
{
  "success": true,
  "data": {
    "bundles": [
      { "credits": 10,  "price": 224,  "pricePerCredit": 23, "discount": "0%"  },
      { "credits": 50,  "price": 897,  "pricePerCredit": 18, "discount": "20%" },
      { "credits": 100, "price": 1569, "pricePerCredit": 16, "discount": "30%" },
      { "credits": 500, "price": 6724, "pricePerCredit": 14, "discount": "40%" }
    ],
    "currency": {
      "asset": "H5FHcnP1MaAet83QJC8KaS5H8bJfUM3kYsWy7nCgBAGS",
      "name": "TRADECRAFT",
      "network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"
    }
  },
  "meta": { "timestamp": "2025-01-15T10:30:00.000Z" }
}

Note: Prices are dynamic and change with the TRADECRAFT/USD market rate. The values above are illustrative. Returns HTTP 503 if the price feed is temporarily unavailable.

Purchase Credits

POST
/v1/credits/purchase?bundle=<size>

Purchase a credit bundle via x402 payment. The payment amount matches the bundle price returned by /bundles.

Query Parameters

NameTypeDescription
bundleintegerBundle size to purchase (10, 50, 100, or 500)
Request (after x402 payment flow)
curl -X POST "https://api.tradecraft.finance/v1/credits/purchase?bundle=50" \
  -H "PAYMENT-SIGNATURE: <signed_payment>"
Response (201)
{
  "success": true,
  "data": {
    "token": "tc_credit_a1b2c3d4e5f6...64 hex chars",
    "credits": 50,
    "pricePaid": 897
  },
  "meta": { "timestamp": "2025-01-15T10:30:00.000Z" }
}

Important: Store the token value securely. It cannot be retrieved again. Treat it like a password.

Error Codes

CodeStatusDescription
INVALID_BUNDLE400Bundle size not available
PRICE_UNAVAILABLE503TRADECRAFT price feed temporarily down

Check Credit Balance

GET
/v1/credits/balance

Check the remaining credit balance for a credit token.

Request
curl -X GET "https://api.tradecraft.finance/v1/credits/balance" \
  -H "Authorization: Bearer tc_credit_<your_token>"
Response (200)
{
  "success": true,
  "data": { "balance": 49 },
  "meta": { "timestamp": "2025-01-15T10:30:00.000Z" }
}

Error Codes

CodeStatusDescription
MISSING_TOKEN401No Authorization header provided
INVALID_TOKEN401Token format is not tc_credit_<...>