Requesting quotes
A quote is a ranked comparison across every eligible rail for a given (source → destination, amount). The response contains a snapshot id, a list of quotes, and a pre-computed best_quote_id. Accept a quote to turn it into an order.
Full flow
import { } from "seismic-orchestration";
const = .();
// (Assume you've already logged in and MFA'd.)
// 1. Price the corridor across every option. wait=true blocks until pricing is complete.
// Omit `rails` on the source to fan out across every USD-in rail. The
// destination is always a registered account; pass its id, or
// `{ account, rails }` to pin a rail.
const = await ..(
{
: "7c4b…",
: "individual",
: "1000",
: { : "USD" },
: "3c92d2a1-…",
},
{ : true },
);
// 2. (Optional) Show the user the ranked list, one entry per rail.
for (const of .) {
.(
`${...(6)} → ${..} ${..} ` +
`rate=${.} fee=${..} ${..}`,
);
}
// 3. Accept the best pick; use `.accept(snapshotId, quoteId, opts)` to override.
// A payment reason is required on every accept.
const order = await ..(., { : "purchase_of_goods" });
Sync vs. async: wait=1
create has two modes, controlled by the wait option.
const quotes = await api.quotes.create(req, { wait: true });
// quotes.status === "ready"; every option has been priced.const quotes = await api.quotes.create(req);
// quotes.status === "pending"; poll quotes.id.
const result = await poll(() => api.quotes.get(quotes.id), (s) => s.status === "ready");
async function poll<T>(
read: () => Promise<T>,
done: (v: T) => boolean,
): Promise<T> {
while (true) {
const v = await read();
if (done(v)) return v;
await new Promise((r) => setTimeout(r, 500));
}
}| Mode | Behavior |
|---|---|
wait: true | Single round-trip. The response blocks until every option has priced. |
| Async (default) | Returns immediately with status: "pending". Poll until status === "ready". |
Picking a quote manually
acceptBest(snapshotId, opts) accepts the server's best_quote_id. To accept a specific entry, use accept with that quote's id:
import { } from "./client";
// The `quoteId` comes from `snapshot.quotes[n].id`.
await ..(, "q_9e4d…", {
: "purchase_of_goods",
});The server returns 400 if quote_id isn't in the snapshot.
Error handling
import { } from "./client";
import { } from "seismic-orchestration";
try {
await ..(
{
: "7c4b…",
: "individual",
: "1000",
: { : "USD" },
: "3c92d2a1-…",
},
{ : true },
);
} catch () {
if ( instanceof && . === 422) {
// No eligible options for this corridor.
} else {
throw ;
}
}The full error taxonomy is at API reference → Errors.
What's next
- Onboarding your end users: provision per-user customer rows before you act against fiat accounts.
- API reference → Quotes: the underlying REST surface and every field.
