Vendo SDKs
Concepts

Events

Subscribe to server-sent events for real-time connection state changes.

Events require Vendo mode (VENDO_API_KEY must be set). events.subscribe() throws VendoOnlyFeature in OSS mode.

The events API delivers a live stream of connection-state changes over SSE. Use it to update your UI in real time or to trigger cache invalidation in your application.

Subscribing

events.subscribe() is an async context manager that yields event objects.

import asyncio
from vendo import AsyncVendo

async def main():
    client = AsyncVendo()
    async with client.events.subscribe() as stream:
        async for event in stream:
            print(event.kind, event.data)
            if event.kind == "connection.connected":
                slug = event.data.get("slug")
                print(f"{slug} connected!")

asyncio.run(main())

Stop by break-ing the loop or cancelling the enclosing Task.

events.subscribe() returns an async iterable.

import { Vendo } from "@vendodev/sdk";

const vendo = new Vendo();

for await (const event of vendo.events.subscribe()) {
  console.log(event.kind, event.data);
  if (event.kind === "connection.connected") {
    const { slug } = event.data;
    console.log(`${slug} connected!`);
  }
}

Use an AbortController to stop cleanly:

const ac = new AbortController();

for await (const event of vendo.events.subscribe({ signal: ac.signal })) {
  if (shouldStop) {
    ac.abort();
    break;
  }
}

events.subscribe() returns an AsyncThrowingStream.

import Vendo

let vendo = try Vendo()
let stream = try vendo.events.subscribe()

for try await event in stream {
    print(event.type, event.data)
    if event.type == "connection.connected" {
        print("A connection was made!")
    }
}

Stop by breaking or cancelling the enclosing Task:

let task = Task {
    for try await event in stream {
        // ...
    }
}
// Later:
task.cancel()

Event types

kind / typeData fieldsDescription
connection.connectedslug, connection_idUser connected an integration
connection.disconnectedslug, connection_idUser disconnected an integration
connection.needs_reauthslug, connection_idOAuth token expired, user must re-authorize
connection.errorslug, messageConnection entered an error state
billing.balance_lowcredits_remaining_microsBalance below configured threshold
billing.balance_exhaustedBalance hit zero
deployment.updatedDeployment settings changed

Auto-reconnect

The stream reconnects automatically with exponential backoff on transient failures:

  • Network drop: reconnects immediately, then backs off (1s, 2s, 4s, ... up to 60s)
  • SSE endpoint returns 5xx: same backoff
  • Three consecutive reconnect failures: the stream yields an error event and closes

Using events with the reconciler

The reconciler uses events.subscribe() internally to invalidate the token cache and re-run the mapping immediately when connections change, instead of waiting for the 30-second poll cycle.

On this page