Build a client with polyester.New(Config{...}) and pass Environment: &polyester.TestnetEnvironment:
a Config without it does not target Testnet. Defaults target API-key trading applications. Unary ConnectRPC responses are limited to 4 MiB after decompression.
Recommended constructor
accountID := "..." // Profile → Account ID
client, err := polyester.New(polyester.Config{
Environment: &polyester.TestnetEnvironment,
APIKeyID: "ak_...",
APIPrivateKey: auth.NewSecret("..."), // 64-char hex from key creation
DefaultAccountID: &accountID,
HydrateCatalogs: true,
// APIURL: "https://api.testnet.polyester.com",
// WSURL: "wss://api.testnet.polyester.com",
// Timeout: 10 * time.Second,
// WireFormat: "binary", // or "json"
// DefaultSubAccountID: &subID,
})
if err != nil { log.Fatal(err) }
defer client.Close()
if err := client.WaitForCatalogs(ctx); err != nil { log.Fatal(err) }Config fields
Environment: API, WebSocket, RPC, and contract pins. Pass&polyester.TestnetEnvironment.APIKeyID/APIPrivateKey: Required for private RPCs / private WS. Default: empty.APIPrivateKeyis anauth.Secret: build it withauth.NewSecret(hexKey)and read it back withcfg.APIPrivateKey.Reveal(). Printing aConfigwith anyfmtverb, or encoding it withencoding/json,encoding/xmlor thelog/slogJSON handler, writes[REDACTED]for the key; gob refuses to encode it. Decoding a JSONConfigstill readsAPIPrivateKey.APIURL: ConnectRPC base override. Default: fromEnvironment.WSURL: Centrifugo WebSocket override. Default: fromEnvironment.DefaultAccountID: Private channel scoping. Default: unset / env fallback.DefaultSubAccountID: Default trading scope. Default: unset.Timeout: HTTP timeout. Default:10s.WireFormat:"binary"or"json". Default: binary.HydrateCatalogs: Background spot + Zipper hydrate. Default: false in zeroConfig; set true for bots.HTTPClient: Optional custom*http.Client. Default: SDK default.
FromEnv sets HydrateCatalogs: true before applying overrides.
Aliases
| Alias | Points to |
|---|---|
client.Candles | client.MarketData |
client.TradingWithdraws | client.Withdraw |
FromEnv
polyester.FromEnv() loads:
POLYESTER_API_KEY_IDPOLYESTER_API_PRIVATE_KEYPOLYESTER_ACCOUNT_ID(optional)POLYESTER_ENV, set totestnet(without it, the client does not target Testnet)POLYESTER_API_URL/POLYESTER_WS_URL(optional overrides)
Override funcs run after these values load. Prefer explicit Config in production.
Catalog readiness
Call
client.WaitForCatalogs(ctx) before decimal order writes that need symbol scales. The wait
fails if either required catalog cannot be hydrated or validated.Retries are application-controlled
The SDK does not automatically retry unary calls, except that
Triggers.Get, Triggers.List and Triggers.ListEvents retry an unavailable answer for up to about 2 seconds. Retry only transport
and rate-limit failures with backoff and stable idempotency keys. Reconcile mutation outcomes
before retrying.Related
Related Topics
Address book Saved destinations and whitelist views. API keys List, get, subscribe, and generate local API key material (no create on API-key SDKs). Auth Auth service helpers including nested profile access. Balances List ledger balances and history, and subscribe to live updates with the Go BalancesService. Candles Read and stream public spot OHLCV candles via MarketData (Candles alias). Catalog Spot/Zipper catalog hydration via HydrateCatalogs and WaitForCatalogs, plus Manager lookups. Chain helpers On-chain Funding → Trading and Funding withdraw helpers. Chain analytics Chain analytics read APIs. Deposit Create and list per-account chain deposit addresses for funding your Polyester account. Errors Go SDK error types, sentinel ErrPolyester, MFA auth codes, and queue overflow. Fees Read effective spot fee rates, reserve rates, the next scheduled change, and the fee breakdown with the Go FeeService. Guard signer Guard signer approval helpers. Heatmap L2 order book heatmap reads. Internal transfers Move trading balances between Polyester accounts without touching a chain. Lifecycle Deposit/withdraw lifecycle flows and subscribe. Market overview List and subscribe to per-market stats with optional snapshot-then-stream merge. Order book Depth snapshots and a stateful live order book that reconstructs the book for you. Orders Place, modify, cancel, batch, and stream spot orders with the Go OrdersService. Policies Realtime API-key and subaccount-policy updates. Profile Profile identity reads and subscribe helpers. Public trades Public trade tape reads and subscribe via MarketData. Realtime Shared Centrifugo client, Messages() delivery, handshake-before-return, and fail-closed overflow. Social verification Social verification APIs (reference-only). Subaccounts Subaccount reads, members, invites, activity. User trades List and stream your private spot fills (not the public tape). Transfers Transfer history reads. Triggers Create, manage, pause/resume, and stream standalone trigger automations with the Go TriggersService. Withdrawals Trading withdraw intents to funding or external chain destinations (signed payload). Zipper Deposit/withdraw config and related Zipper reads.