Event streaming

Your integration may wish to receive real time updates from Bias for fulfilling paid orders, updating your own records of payment data, or other purposes. For this reason, the Event List resources includes a stream option that will return a long-lived stream of events.

Streamed responses consist of JSON objects, separated by newlines. They are not wrapped in the usual List object, they are plain Event objects. The server will send a space character every few seconds to ensure the connection is not ended prematurely.

Example

Listen for new customers and log their names:

const stream = await sdk.events.list({
    stream: true, // Request a stream instead of a list
    filters: { type: "customer.created" },
});

for await (const event of stream) {
    const customer = event.state as Customer;
    console.log(`New customer: ${customer.name}`)
}