puter.workers.list()

Websites Puter Apps Node.js Workers

Lists all workers in your account with their details.

Syntax

puter.workers.list()
puter.workers.list(options)

Parameters

options (Object) (optional)

An object with the following optional properties:

Option Type Description
limit Number Maximum number of workers to return in a single call.
cursor String | null Opts into paginated results. Pass null for the first page, then the cursor from each page to fetch the next one.
stream Boolean If true, the method returns an async iterator of page objects instead of a promise, for use with for await ... of. Combine with limit to control the page size, or cursor to resume from a previous page. Cannot be combined with offset. With includeTotal, only the first page carries total.
includeTotal Boolean If true, the paginated result includes a total count.
offset Number Skips the given number of workers. Prefer cursor for paging through large lists.

Return value

A Promise that resolves to a WorkerInfo array with each worker's information.

When the request includes any pagination option, the promise instead resolves to a page object:

  • items (Array): The WorkerInfo objects on this page.
  • cursor (String) (optional): Present while more pages exist; pass it to the next call.
  • total (Number) (optional): Present when includeTotal was set.

Without pagination params, the full list is returned as a plain array.

With stream: true, the method returns an async iterator of page objects instead:

for await (const page of puter.workers.list({ stream: true })) {
    for (const worker of page.items) {
        console.log(worker.name);
    }
}

Examples

List all workers

<html>
<body>
    <script src="https://js.puter.com/v2/"></script>
    <script>
        (async () => {
            // List all workers
            const workers = await puter.workers.list();
            puter.print(`You have ${workers.length} worker(s):<br>`);
            workers.forEach(worker => {
                puter.print(`- ${worker.name} (${worker.url})<br>`);
            });
        })();
    </script>
</body>
</html>