Mint a token and make your first call
Every REST call is authenticated with a short-lived bearer token you mint yourself from a long-lived credential. You end up with a token, the two headers every later call needs, and a response that proves both of them resolved.
-
Exchange the credential for a token
Section titled “Exchange the credential for a token”POST /api/auth/api-tokentakes{ apiKey, apiSecret }and returns a 24-hour HS256 JWT intoken. The credential pair itself is issued out of band — by an operator in the admin console, or by self-serve tenant signup where that is enabled. See Credentials & tokens.Terminal window curl -s https://api.troncharts.xyz/api/auth/api-token \-H 'content-type: application/json' \-d '{"apiKey":"'"$TC_API_KEY"'","apiSecret":"'"$TC_API_SECRET"'"}'# → { "token": "eyJ…", "tier": "fullTrading", "accountId": "…",# "expiresAt": 1754300000000, "enabledTools": null, … }import { TronCharts } from '@tronchartsxyz/api-client'// The mint path authenticates from the body, so the minting client// needs no token of its own.const minter = new TronCharts({ baseUrl: 'https://api.troncharts.xyz', token: '' })const { token } = await minter.auth.apiToken({apiKey: process.env.TC_API_KEY!,apiSecret: process.env.TC_API_SECRET!,})tieris snapshotted at mint: a tier change on the credential needs a fresh token to take effect. -
Send the token and the tenant together
Section titled “Send the token and the tenant together”GET /api/v1/_meta/test-connectionis the one round-trip that confirms the bearer, the tenant and the tier all resolved. It returns{ ok, accountId, apiClientId, tier, serverTime }.Terminal window curl -s https://api.troncharts.xyz/api/v1/_meta/test-connection \-H "authorization: Bearer $TOKEN" \-H "x-tenant-slug: $TC_TENANT_SLUG"# → { "ok": true, "accountId": "…", "apiClientId": "…",# "tier": "fullTrading", "serverTime": "2026-08-04T12:00:00.000Z" }const sdk = new TronCharts({baseUrl: 'https://api.troncharts.xyz',token,tenantSlug: process.env.TC_TENANT_SLUG!, // sent as x-tenant-slug on every request})// No typed resource wraps /_meta; sdk.client is the escape hatch.const who = await sdk.client.request<{ ok: boolean; accountId: string; tier: string }>('/api/v1/_meta/test-connection',) -
Read something back
Section titled “Read something back”GET /api/v1/accountslists every account the credential can reach and gives you theaccountIdthat every/api/v1/accounts/{id}/*read needs.Terminal window curl -s https://api.troncharts.xyz/api/v1/accounts \-H "authorization: Bearer $TOKEN" \-H "x-tenant-slug: $TC_TENANT_SLUG"# → { rootAccountId, activeAccountId,# accounts: [ { accountId, accountNumber, kind, capitalModel,# displayName, baseCurrency, wallets: [...] } ] }const { accounts } = await sdk.accounts.list()// The route sends `accountId` on each row; the SDK's `id` field is not// on the wire in 0.3.0.const accountId = accounts[0]!.accountId as stringRevoke a token before its 24 hours are up with
POST /api/auth/api-token/revokeand{ token }.
Next: Create a paper account · Read balance, positions and open orders · Scopes & tiers