ApifyClient.API.Tasks.Runs (apify_client v1.0.0)

Copy Markdown View Source

Provides API endpoints related to api/tasks/runs

Summary

Types

create_201_json_resp()

@type create_201_json_resp() :: %{data: ApifyClient.Schemas.Run.t()}

list_200_json_resp()

@type list_200_json_resp() :: %{data: list_200_json_resp_data()}

list_200_json_resp_data()

@type list_200_json_resp_data() :: %{
  count: integer() | nil,
  desc: boolean() | nil,
  items: [ApifyClient.Schemas.RunListItem.t()] | nil,
  limit: integer() | nil,
  offset: integer() | nil,
  total: integer() | nil
}

Functions

create(actor_task_id, body, opts \\ [])

@spec create(actor_task_id :: String.t(), body :: any(), opts :: keyword()) ::
  {:ok, ApifyClient.Schemas.Run.t()} | {:error, ApifyClient.Error.t()}

Run Actor task

Runs an Actor task and immediately returns without waiting for the run to finish.

Optionally, you can override the Actor input configuration by passing a JSON object as the POST payload and setting the Content-Type: application/json HTTP header.

Note that if the object in the POST payload does not define a particular input property, the Actor run uses the default value defined by the task (or Actor's input schema if not defined by the task).

The response is the Actor Run object as returned by the Get Actor run endpoint.

If you want to wait for the run to finish and receive the actual output of the Actor run as the response, use the Run Actor task synchronously and get key-value store record or Run Actor task synchronously and get dataset items endpoint instead.

To fetch the Actor run results that are typically stored in the default dataset, you'll need to pass the ID received in the defaultDatasetId field received in the response JSON to the Get dataset items API endpoint.

Options

  • timeout: Optional timeout for the run, in seconds. By default, the run uses the timeout from its configuration.

  • memory: Memory limit for the run, in megabytes. You can set the amount of memory to a power of 2 with a minimum of 128. By default, the run uses the memory limit from its configuration. Don't change this value unless the Actor's documentation recommends it or you're aware of the consequences.

  • max_items: Specifies the maximum number of dataset items that will be charged for pay-per-result Actors. This does NOT guarantee that the Actor will return only this many items. It only ensures you won't be charged for more than this number of items. Only works for pay-per-result Actors. Value can be accessed in the actor run using ACTOR_MAX_PAID_DATASET_ITEMS environment variable.

  • max_total_charge_usd: Specifies the maximum total cost of the run. Use it to cap the total amount charged for all pricing models. You can access the maximum cost in your Actor by using the ACTOR_MAX_TOTAL_CHARGE_USD environment variable.

  • restart_on_error: Determines whether the run will be restarted if it fails.

  • build: Specifies the Actor build to run. It can be either a build tag or build number. By default, the run uses the build from its configuration (typically latest).

  • wait_for_finish: The maximum number of seconds the server waits for the run to finish. By default it is 0, the maximum value is 60. <!-- MAX_ACTOR_JOB_ASYNC_WAIT_SECS --> If the run finishes in time then the returned run object will have a terminal status (e.g. SUCCEEDED), otherwise it will have a transitional status (e.g. RUNNING).

  • webhooks: Specifies optional webhooks associated with the Actor run, which can be used to receive a notification e.g. when the Actor finished or failed. The value is a Base64-encoded JSON array whose items follow the WebhookRepresentation schema. For more information, see Webhooks documentation.

Request Body

Content Types: */*, application/json

list(actor_task_id, opts \\ [])

@spec list(actor_task_id :: String.t(), opts :: keyword()) ::
  {:ok, list_200_json_resp_data()} | {:error, ApifyClient.Error.t()}

Get list of Actor task's runs

Get a list of runs of a specific task. The response is a list of objects, where each object contains essential information about a single task run.

The endpoint supports pagination using the limit and offset parameters, and it does not return more than a 1000 array elements.

By default, the records are sorted by the startedAt field in ascending order; therefore you can use pagination to incrementally fetch all records while new ones are still being created. To sort the records in descending order, use the desc=1 parameter. You can also filter runs by status (available statuses).

Options

  • offset: Number of items that should be skipped at the start. The default value is 0.

  • limit: Maximum number of items to return. The default value as well as the maximum is 1000.

  • desc: If true or 1 then the objects are sorted by the startedAt field in descending order. By default, they are sorted in ascending order.

  • status: Single status or comma-separated list of statuses, see (available statuses). Used to filter runs by the specified statuses only.