Skip to main content
Version: Next

TaskCollectionClient

Client for managing the collection of Actor tasks in your account.

Tasks are pre-configured Actor runs with saved input and options. This client provides methods to list and create tasks.

@example
const client = new ApifyClient({ token: 'my-token' });
const tasksClient = client.tasks();

// List all tasks
const { items } = await tasksClient.list();

// Create a new task
const newTask = await tasksClient.create({
actId: 'my-actor-id',
name: 'my-task',
input: { url: 'https://example.com' }
});
@see

Hierarchy

  • ResourceCollectionClient
    • TaskCollectionClient

Index

Properties

inheritedapifyClient

apifyClient: ApifyClient

inheritedbaseUrl

baseUrl: string

inheritedhttpClient

httpClient: HttpClient

optionalinheritedid

id?: string

optionalinheritedparams

params?: Record<string, unknown>

inheritedpublicBaseUrl

publicBaseUrl: string

inheritedresourcePath

resourcePath: string

optionalinheritedsafeId

safeId?: string

inheritedurl

url: string

Methods

create

  • create(task): Promise<Task>

list

  • list(options): PaginatedIterator<TaskList>
  • Lists all Tasks.

    Awaiting the return value (as you would with a Promise) will result in a single API call. The amount of fetched items in a single API call is limited.

    const paginatedList = await client.list(options);

    Asynchronous iteration is also supported. This will fetch additional pages if needed until all items are retrieved.

    for await (const singleItem of client.list(options)) {...}
    @see

    Parameters

    Returns PaginatedIterator<TaskList>

    A paginated iterator of tasks.