Examples
These examples show the current private-beta integration shape. The public npm
release is @sentico-labs/sdk 0.3.0; repository examples compile against the
repository SDK version, currently 0.4.0. Market makers should begin with the
Market Maker Beta Quickstart.
TypeScript Public Reads
Download the self-contained npm 0.3.0 quickstart to run this without a repository checkout.
import { SenticoreClient } from "@sentico-labs/sdk";
const client = new SenticoreClient({
publicHttpBaseUrl: "https://api.sentico-labs.xyz",
tradingHttpBaseUrl: "https://api.sentico-labs.xyz",
publicWsUrl: "wss://api.sentico-labs.xyz/api/v1/ws/public",
privateWsUrl: "wss://api.sentico-labs.xyz/api/v1/ws/private/{account}",
});
const markets = await client.public.listMarkets();
const snapshot = await client.public.getMarketSnapshot(1);
BSL Compact Submit
await client.orderEntry.submitActions([signedAction], {
idempotencyKey: "quote-refresh-1",
responseMode: "detailed",
headers: { "x-bsl-result-mode": "ack" },
orderEntryApiKey: process.env.SENTICORE_ORDER_ENTRY_API_KEY,
});
This submits compact JSON bytes to:
POST /api/order-entry/binary
Content-Type: application/x-senticore-order-entry-batch
X-BSL-Result-Mode: ack
X-Senticore-Response-Mode: detailed
Wallet or delegated signatures inside the action batch are still required. The optional order-entry key only authorizes a dedicated lane and rate tier.
Private Stream Resume
The complete published-SDK source is
private-stream.mjs in the
quickstart archive.
// The issuing credential needs `read` scope (an agent key without it gets permission_denied).
const stream = client.ws.reliablePrivate({
account,
tokenProvider: () => client.trading.issuePrivateWsToken(account, { ttlMs: 180_000 }),
// orderUpdates resume requires cursorNamespace "execution-v1"; cursors are u64 decimal strings.
subscriptions: [{ type: "orderUpdates", cursorNamespace: "execution-v1" }, { type: "userFills" }],
onEvent: (frame, ctx) => strategy.apply(frame, ctx),
// resume_required (1005) is routine right after a deploy: rebuild from REST, then resume.
onResyncRequired: (details) => strategy.rebuildFromRest(details),
});
await stream.start();
Python Public Reads
from senticore import SenticoreClient, SenticoreConfig
client = SenticoreClient(
SenticoreConfig(
public_http_base_url="https://api.sentico-labs.xyz",
trading_http_base_url="https://api.sentico-labs.xyz",
)
)
markets = client.public.list_markets()
print(markets.data)
client.close()
Integration Checklist
- Use the tested beta route bundle before switching to canonical BSL aliases.
- Use
Idempotency-Keyfor every retriable mutation. - Persist nonce, idempotency key, derived order id, and client order id.
- Treat the submit response as an admission ACK. Confirm terminal state through
orderUpdatesorgetOrderReceipt(account, seq)before considering the lifecycle complete. - On an ambiguous submit result, reconcile the original idempotency key, sequence/order id and nonce. Do not automatically sign a replacement order.
- Handle
429with bounded backoff and jitter. - Treat
SHARD_BUSY,QUEUE_LIMIT,RISK_CREDIT_LIMIT,KILL_SWITCH, andTRADING_HALTEDas strategy-level events. - Remember that a
QuoteReplaceis atomic: one inadmissible ask leg drops the whole action, bids included (see Batch atomicity). - Keep owner wallet keys out of bots and quote engines.
- Run
node scripts/e2e/mm-docs-contract-audit.cjsagainst the target account.