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 one header every later call needs, and a response that proves it 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, but every call re-reads the credential: a downgrade takes effect on the next request, while an upgrade needs a fresh token. -
Make your first call
Section titled “Make your first call”GET /api/v1/accountslists every account the credential can reach and gives you theaccountIdthat every/api/v1/accounts/{id}/*read needs. A200here is the proof that the token resolved: the tenant comes from the credential itself, so no tenant header is needed on a bearer call. A missing or broken token answers401(see Credentials & tokens).Terminal window curl -s https://api.troncharts.xyz/api/v1/accounts \-H "authorization: Bearer $TOKEN"# → { rootAccountId, activeAccountId,# accounts: [ { accountId, accountNumber, kind, capitalModel,# displayName, baseCurrency, wallets: [...] } ] }const sdk = new TronCharts({ baseUrl: 'https://api.troncharts.xyz', token })const { accounts } = await sdk.accounts.list()// The route sends `accountId` on each row; the SDK's `id` field is not// on the wire (checked against 0.4.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