SDK Client#
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.
1const rfq = await tetrafi.rfq.create({2pair: "USDC/USDT",3side: "buy",4amount: "1000000.00",5corridor: "ethereum-optimism",6maxSlippage: 0.001,7});rfq.getQuotes(rfqId) / rfq.get_quotes(rfq_id) Stable#
Get competing quotes for an active RFQ. Returns list sorted best-price-first.
rfq.acceptBest(rfqId) / rfq.accept_best(rfq_id)#
Automatically select and accept the best available quote.
quotes.accept(quoteId) / quotes.accept(quote_id)#
Accept a specific quote and trigger escrow creation.
settlements.get(id)#
Get the current status of a settlement.
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.
| Channel | When it fires |
|---|---|
rfq.created | Your RFQ has been broadcast to solvers |
quote.received | A solver returned a quote |
quote.accepted | You accepted a quote |
settlement.pending | Settlement initiated, escrow locking |
settlement.complete | Both legs settled atomically |
settlement.failed | Settlement reverted, refund issued |
rfq.* / settlement.* | Wildcard - all events in that namespace |
Full Working Example#
Error Handling#
Type Definitions#
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}1112interface Quote {13 id: string;14 rfqId: string;15 solverId: string;16 price: string;17 ttl: number;18 confidence: number;19 createdAt: string;20}2122interface 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}3334interface ComplianceStatus {35 address: string;36 isCompliant: boolean;37 attestationHash: string;38 expiresAt: string;39}Versioning#
Both packages follow semver. Pin to exact versions for production deploys.
| Bump | Meaning | Action |
|---|---|---|
1.0.x → 1.0.y | Patch - bug fixes | Auto-update safe |
1.0.x → 1.1.x | Minor - new methods | Read changelog |
1.x → 2.0 | Major - breaking | Migration guide required |