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. Platform keys can act on behalf of any end-user they have provisioned. Legacy direct-user keys can only call 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.

Quickstart

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

1. Register your platform
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: "grow_monthly",
  }),
});
const { platform, api_key } = await res.json();
console.log("Save this key now:", api_key);
2. Provision an end-user
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
Ask Trade AI to fetch fresh OHLCV and run the signal engine on demand. 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",
});
3b. Publish your own signal to your end-users
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)
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);

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
}

Ready to build?

Mint your first key with the onboarding wizard, then drop the SDK into your project.