v1 · Stable

Trade AI API

Programmatic access to AI trading signals, portfolio insights, chart analysis, and Telegram delivery — for your end-users, under your brand.

SDKs

TypeScript
Zero-dependency client. Node 18+, Bun, Deno, edge.
// Drop-in single file
curl -O https://tradeai.smartchain.consulting/api/public/v1/sdk/typescript
Download tradeai.ts
Python
Pure stdlib — no extra installs needed. Python 3.9+.
curl -O https://tradeai.smartchain.consulting/api/public/v1/sdk/python
Download tradeai.py

Authentication

Every request carries a Bearer token. API keys are issued only to accounts on a Business plan — Individual plans (Free, Pro) are dashboard-only. A Business key can act on behalf of any end-user it has provisioned, and on the Business account itself for the unscoped endpoints.

Authorization: Bearer tsk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
End-users never log into Trade AI.Your platform is the only Trade-AI account holder. Every action on behalf of one of your users — provisioning, signals, portfolio, charts, Telegram linking and messaging — flows through /users/{id}/... with your platform key. There is no end-user UI hosted on Trade AI.

Plan access

The API is a Business product. Each plan unlocks a specific set of endpoints; calling anything outside your plan returns 403 PlanUpgradeRequired with the missing capability.

PlanTrading APITelegram APIMarket Data APIBroadcastReq/min
Business Starter $49/moIncluded20
Business Pro $99/moIncludedIncluded40
Business Ultra $149/moIncludedIncludedIncludedIncluded55
Business Market $49/moIncluded20

Trading API = signals, charts, portfolio, AI functions and summarize. News and sentiment are included with every Business plan. Individual plans do not include API keys, webhooks or the market data feed.

Quickstart

Five steps from zero to pushing a signal into a user's Telegram.

1. Register your platform
Any Business plan
Mint your first API key. The Bearer token is shown only once — store it in a vault.
// Registration is unauthenticated — call once from your provisioning script.
const res = await fetch("https://tradeai.smartchain.consulting/api/public/v1/platforms/register", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    owner_user_id: process.env.TRADEAI_OWNER_ID,
    company_name: "Acme Brokerage",
    contact_email: "ops@acme.io",
    country: "US",
    activity: "trading_platform",
    user_size_band: "501_10k",
    plan_slug: "biz_starter_monthly",
  }),
});
const { platform, api_key } = await res.json();
console.log("Save this key now:", api_key);
2. Provision an end-user
Starter
Pro
Ultra
Every downstream call is scoped to one of your end-users. Create them with your stable external id.
import { TradeAI } from "./tradeai";
const client = new TradeAI({ apiKey: process.env.TRADEAI_KEY! });

const user = await client.users.create({
  external_user_id: "u_42",
  first_name: "Ada",
  last_name: "Lovelace",
  email: "ada@example.com",
});
3. Generate an AI trading signal
Starter
Pro
Ultra
Ask Trade AI to fetch fresh OHLCV and run the signal engine on demand. The response includes entry / stop / targets, locally-computed bias and pivot support/resistance (no AI cost), an indicators snapshot, a localized `summary`, and an annotated `chart_url` (candlestick with EMA20/50, S/R, entry/SL/TP) you can embed directly via `<img src={chart_url}>`. Pass `include_chart: false` to skip the chart for lower bandwidth. Pass a `strategy` to lock SL/TP to a trading-category profile (overrides ATR): `aggressive_scalping` (M5–M15, TP 5/7/10, SL 5), `moderate_scalping` (M15–M30, TP 7/12/16, SL 10), `swing_trading` (M30–H4, TP 15/25/35, SL 12), `forex_aggressive` (H4–D1, TP 25/35/45, SL 16), plus `forex_moderate`, `forex_conservative`, and commodities / crypto / indices tiers. Markets covered — US equities (NYSE/Nasdaq/AMEX) and global crypto/forex/commodities are real-time via our primary feeds; international equities (LSE, XETRA, Euronext, SIX, TSE, HKEX, NSE/BSE, KRX, ASX, TSX, B3, …) use the global feed with a TICKER.EXCHANGE suffix (e.g. BMW.DE, 7203.T, RELIANCE.NSE) and may be real-time or delayed depending on entitlement. Pass `language` (ISO 639-1 like `ar`, `fr`, `en`) — or omit it and we auto-detect from the input or the `Accept-Language` header — to get the response in that language. The same `language` field works on `/charts/analyze-symbol`, `/charts/analyze-image`, `/portfolio/insights`, `/summarize`, and `/ai/run`.
const signals = await client.signals.generate(user.id, {
  asset_class: "crypto",
  symbol: "BTC/USD",
  timeframe: "1Hour",
  language: "en", // or omit to auto-detect from Accept-Language
  preset: "swing", // scalping | swing | price_action | trend | mean_reversion | custom
  strategy: "swing_trading", // aggressive_scalping | moderate_scalping | swing_trading | forex_aggressive | forex_moderate | forex_conservative | commodities_* | crypto_* | indices_*
  indicators: ["ema", "rsi", "macd", "bbands", "atr"],
  params: {
    ema: { fast: 20, slow: 50 },
    rsi: { period: 14, overbought: 70, oversold: 30 },
    atr: { period: 14, sl_mults: [1, 1.5, 2], tp_mults: [1.5, 2.5, 4] },
  },
  weights: { ema: 1.5, rsi: 1, macd: 1 },
  include_chart: true,
});
// → entry, stop_losses {sl1, sl2, sl3}, take_profits {tp1, tp2, tp3},
//   bias, support[], resistance[], indicators, summary, chart_url
3b. Publish your own signal to your end-users
Ultra
Curated signal from your team — visible only to your platform's end-users (NOT to other Trade AI users). Triggers a `signal.published` webhook to your endpoints. Available on any active paid plan.
await client.platforms.signals.publish({
  asset_class: "crypto",
  symbol: "BTCUSD",
  side: "long",
  entry: 64500,
  targets: [66000, 68000],
});
5. Link & message end-users on Telegram (API-only)
Pro
Ultra
End-users never visit Trade AI. Your backend mints a one-time code, your app shows the instructions, then you poll for status and push messages — all through the API. Use your own platform's child bot (configure it under Platform → Telegram child bot).
// 1. Mint a one-time code
const { link_code } = await client.telegram.linkCode(user.id);

// 2. In YOUR own UI, render:
//    "Open @{botUsername} and send /start {link_code}"
const { bot_username } = await client.telegram.status(user.id);

// 3. Poll status until linked
let status = await client.telegram.status(user.id);
while (!status.linked) {
  await new Promise((r) => setTimeout(r, 3000));
  status = await client.telegram.status(user.id);
}

// 4. Push messages
await client.telegram.send(user.id, "BTC just printed a long signal at $63,420.");

// 5. Unlink when the user asks (inside your app)
await client.telegram.unlink(user.id);
6. Market data (quotes, candles, EOD, indicators)
Ultra
Market
The Market Data API is billed on its own plan. Real-time quotes, OHLCV candles, end-of-day closes, symbol reference and computed indicator values across equities, ETFs, FX, crypto and commodities. Add `/users/{id}/…` to attribute usage to one of your end-users.
// Real-time quotes
const quotes = await client.market.quote({ symbol: ["AAPL", "MSFT"], asset_class: "equities" });

// OHLCV candles
const candles = await client.market.ohlcv({
  symbol: "EUR/USD",
  asset_class: "forex",
  timeframe: "1Hour",
  limit: 200,
});

// End-of-day close
const eod = await client.market.eod({ symbol: "SPY" });

// Symbol search
const found = await client.market.symbols({ q: "apple", limit: 10 });

// Indicator values with custom periods
const indicators = await client.market.indicators({
  symbol: "BTC/USD",
  asset_class: "crypto",
  timeframe: "1Hour",
  indicators: ["ema", "rsi", "macd", "atr", "pivots"],
  params: { rsi: { period: 9 } },
});

// Attribute usage to one of your end-users
const perUser = await client.market.quote({ symbol: "TSLA", userId: user.id });

// Public ticker board (no key required)
const board = await client.market.ticker();

Rate limits & quotas

Each response includes X-Quota-Limit, X-Quota-Used, X-Quota-Remaining, and X-Quota-Reset (unix seconds for the next month). Watch them in production to avoid surprises.

Open the quota dashboard

Error responses

Errors return a JSON body with a stable error field and a human-readable message. The SDKs raise TradeAIError with the HTTP status and parsed body attached.

{
  "error": "rate_limited",
  "message": "Plan quota exceeded for this minute. Retry in 12s.",
  "retry_after_seconds": 12
}