@kernlog/brdg-sdk has one method per endpoint, with request and response types generated from the API’s OpenAPI document. It has no runtime dependencies and runs on Node 18 or later, or any runtime with a global fetch. It ships ESM and CommonJS builds.
Source code and releases are on GitHub.
Example
Fast fill
getFastFillQuote, buildFastFill and submitFastFillSignature cover the fast fill lane, from version 0.5.0. Send a vm: "sign" step’s signature with submitFastFillSignature, and every transaction step with submitTransfer.
Referrals
resolveReferral and getReferralLeaderboard cover the referral program, and getQuote and getFastFillQuote accept referralCode, from version 0.6.0. The SDK trims and lower-cases referralCode and throws a BrdgError with the code invalid_referral_code before sending a malformed one.
Configuration
All options are optional.apiKey is for partners calling from a server: with it, the per-IP limit applies to the userIp on each request instead of your server. Higher limits are available on request: contact @kernlog on Telegram or kernlog@print.world. See Higher rate limits and partner access.
retry (true, or { retries, baseDelayMs, maxDelayMs, maxRetryAfterMs }) uses exponential backoff with jitter and waits at least what Retry-After asks. Reads retry on 429, 5xx and network failures. Quote, build and submit retry only on 429 rate_limited, where nothing was done; any other failure on them is thrown, because a build or submit may have happened. waitForTransfer always polls through temporary read failures until its timeout.
Errors
When the API returns an error, the SDK throws aBrdgError with the API’s code, the HTTP status, details and, on a 429, retryAfterMs. The codes are listed on Errors.
Methods
waitForTransfer polls every 3 seconds and gives up after 20 minutes by throwing a TransferTimeoutError. Change either with intervalMs and timeoutMs, and pass onUpdate to see each status as it arrives.
Every request and response type is exported, for example import type { QuoteResponse, BuildStep, Transfer } from '@kernlog/brdg-sdk'.