Skip to content

SDK Overview

@tokenbot-org/sdk is a typed TypeScript client wrapping TokenBot’s REST and GraphQL APIs. It is the same SDK the tokenbot CLI is built on.

There is one SDK, and it is TypeScript. The standalone Python and Node SDK repositories were retired on 2026-06-28. If you need TokenBot from another language, call the REST API or GraphQL API directly — both use the same signed-request scheme described below.


Published to GitHub Packages, so you need an .npmrc pointing the @tokenbot-org scope there:

@tokenbot-org:registry=https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}
Terminal window
npm install @tokenbot-org/sdk @tokenbot-org/cli-core

@tokenbot-org/cli-core is a peer concern, not an optional extra: it owns identity, passphrase handling and the signed HTTP transport. The SDK is deliberately stateless and takes a pre-constructed SignedHttpClient.


The SDK does not take an API-key string. Every request is signed with a secp256k1 private key over a canonical string, and the server verifies the signature. There is no shared bearer secret to leak.

import { SignedHttpClient, unlockIdentity } from '@tokenbot-org/cli-core';
import { TokenbotSdk } from '@tokenbot-org/sdk';
const privateKey = unlockIdentity(encryptedKey, salt, passphrase);
const http = new SignedHttpClient({
apiUrl: 'https://api.tokenbot.com',
publicKey,
privateKey,
});
const sdk = new TokenbotSdk({
http,
graphqlUrl: 'https://gql-api.tokenbot.com/graphql',
wsUrl: 'wss://gql-api.tokenbot.com/graphql', // only needed for *Watch subscriptions
});

graphqlUrl matters. REST and GraphQL are deployed on different hosts, and rest-api has no /graphql passthrough — sending GraphQL through the REST transport 404s. When you pass graphqlUrl, the SDK re-points a copy of the signed transport at that origin, preserving your identity.

The easiest way to get a keypair is tokenbot init, which writes an encrypted identity to ~/.tokenbot/config.json.


NamespaceTransportMethods
sdk.strategiesGraphQLlist, get, create, update, delete
sdk.copiersGraphQLlist, get, create, update, link, unlink, delete
sdk.tradesGraphQLlist, get
sdk.exchangesRESTlistAccounts, getAccount, createAccount, deleteAccount, listSupported
sdk.webhooksRESTlist, create, delete, test
sdk.apiKeysRESTlist, create, revoke
sdk.identityRESTwhoami, getChallenge, register
sdk.settingsRESTget, update
sdk.rewardsGraphQLsummary, referralCode
sdk.adminGraphQLadmin-only operations
sdk.mmgraphql-wsorderBookWatch (subscription)

Every failure is a typed subclass of SdkError:

ErrorMeaning
SdkAuthErrorsignature rejected, or identity not registered
SdkPermissionErrorauthenticated but not allowed
SdkNotFoundErrorno such resource
SdkValidationErrorresponse failed schema validation
SdkHttpErrornon-2xx with no more specific mapping
SdkGraphqlErrorGraphQL returned an errors array
SdkNetworkErrortransport failed before a response
SdkAdminEndpointMissingErroradmin endpoint absent on the target deployment

Responses are validated against schemas, so a shape change surfaces as SdkValidationError at the boundary rather than as an undefined field somewhere downstream.