Skip to main contentSkip to FAQSkip to contact
For TakersPlanned4 min read

SDK Client#

Planned Specification. Both packages are under development. Use the REST API and WebSocket directly until release.

Installation#

Python requires 3.10+, httpx, websockets.

Initialization#

apiKey / api_keystringrequired
Your API key (tfk_test_* for sandbox, tfk_live_* for production)
environmentstring
'sandbox' | 'production'. Defaults to 'production'.Default: production
timeoutnumber
Request timeout (ms in TS, seconds in Python).Default: 30000 / 30
retriesnumber
Auto-retry count on 5xx errors.Default: 3
baseUrl / base_urlstring
Override the API base URL. Useful for proxies or local development.

Core Methods#

rfq.create(params) Stable#

Submit a new RFQ to competing solvers.

Annotated parameters
1const rfq = await tetrafi.rfq.create({
2pair: "USDC/USDT",
3side: "buy",
4amount: "1000000.00",
5corridor: "ethereum-optimism",
6maxSlippage: 0.001,
7});
7 linestypescript
ReturnsRFQ

rfq.getQuotes(rfqId) / rfq.get_quotes(rfq_id) Stable#

Get competing quotes for an active RFQ. Returns list sorted best-price-first.

ReturnsQuote[]- sorted best-price first

rfq.acceptBest(rfqId) / rfq.accept_best(rfq_id)#

Automatically select and accept the best available quote.

ReturnsSettlement

quotes.accept(quoteId) / quotes.accept(quote_id)#

Accept a specific quote and trigger escrow creation.

ReturnsSettlement

settlements.get(id)#

Get the current status of a settlement.

ReturnsSettlement

compliance.check(address)#

Check whether an address has a valid compliance attestation.

events.on(type, callback) Beta#

Subscribe to real-time events via WebSocket. TypeScript uses a callback pattern; Python uses async for.

ChannelWhen it fires
rfq.createdYour RFQ has been broadcast to solvers
quote.receivedA solver returned a quote
quote.acceptedYou accepted a quote
settlement.pendingSettlement initiated, escrow locking
settlement.completeBoth legs settled atomically
settlement.failedSettlement reverted, refund issued
rfq.* / settlement.*Wildcard - all events in that namespace

Full Working Example#

Error Handling#

Type Definitions#

TypeScript
1interface RFQ {
2 id: string;
3 pair: string;
4 side: "buy" | "sell";
5 amount: string;
6 corridor: string;
7 status: "pending" | "quoting" | "accepted" | "expired";
8 createdAt: string;
9 expiresAt: string;
10}
11
12interface Quote {
13 id: string;
14 rfqId: string;
15 solverId: string;
16 price: string;
17 ttl: number;
18 confidence: number;
19 createdAt: string;
20}
21
22interface Settlement {
23 id: string;
24 rfqId: string;
25 quoteId: string;
26 status: "pending" | "escrow_locked" | "filling" | "complete" | "failed" | "refunded";
27 originTxHash?: string;
28 destinationTxHash?: string;
29 amount: string;
30 createdAt: string;
31 settledAt?: string;
32}
33
34interface ComplianceStatus {
35 address: string;
36 isCompliant: boolean;
37 attestationHash: string;
38 expiresAt: string;
39}
39 linestypescript

Versioning#

Both packages follow semver. Pin to exact versions for production deploys.

BumpMeaningAction
1.0.x → 1.0.yPatch - bug fixesAuto-update safe
1.0.x → 1.1.xMinor - new methodsRead changelog
1.x → 2.0Major - breakingMigration guide required

See Also#

Related topics