Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Pratyay360/podman-ts/llms.txt

Use this file to discover all available pages before exploring further.

EventsManager (exposed as client.events) gives you a live stream of Podman service events as an async generator. Because it uses stream: true under the hood, you iterate over events with a standard for await...of loop — there is no separate stream() method.

list(options?)

client.events.list(options?: EventsListOptions): AsyncGenerator<string | Record<string, unknown>>
Opens a streaming GET /events request and yields one item per newline-delimited event. When the generator is exhausted the connection has closed on the server side.

EventsListOptions

OptionTypeDescription
sinceDate | numberReturn events that occurred after this timestamp. Accepts a Date object or a Unix timestamp (seconds).
untilDate | numberStop returning events after this timestamp.
filtersRecord<string, string | string[]>Key/value filters forwarded to the Podman API (e.g. { type: "container" }).
decodebooleanWhen true, each yielded value is a parsed Record<string, unknown>. Otherwise a raw JSON string is yielded.

Basic usage

Iterate over all incoming events and print each one as a parsed object:
import { PodmanClient } from "@pratyay360/podman-ts";

const client = new PodmanClient();

for await (const line of client.events.list({ decode: true })) {
  const event = line as Record<string, unknown>;
  console.log(event);
}

Filtering events by type

Pass a filters map to narrow the stream. The keys and values mirror the Podman API filter syntax:
// Only receive container events
for await (const line of client.events.list({
  decode: true,
  filters: { type: "container" },
})) {
  const event = line as Record<string, unknown>;
  console.log(event["Action"], event["Actor"]);
}
// Only receive image pull/push events since a specific point in time
const since = new Date(Date.now() - 60_000); // last 60 seconds

for await (const line of client.events.list({
  decode: true,
  since,
  filters: { type: "image" },
})) {
  console.log(line);
}

Raw string mode

Omit decode (or set it to false) to receive the raw newline-delimited JSON strings. This is useful when you want to forward events to another sink without the overhead of parsing:
for await (const raw of client.events.list()) {
  process.stdout.write(raw + "\n");
}
There is no separate stream() method on EventsManager. Always use for await...of client.events.list() to consume the event stream.

Build docs developers (and LLMs) love