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

Copy Markdown View Source

Provides API endpoints related to api/actors/runs

Summary

Types

resurrect_200_json_resp()

@type resurrect_200_json_resp() :: %{data: ApifyClient.Schemas.Run.t() | nil}

Functions

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

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

Run Actor

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

The POST payload including its Content-Type header is passed as INPUT to the Actor (usually application/json).

The Actor is started with the default options; you can override them using various URL query parameters.

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

If you want to wait for the run to finish and receive the actual output of the Actor as the response, please use the Run Actor synchronously and get key-value store record or Run Actor 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.

  • force_permission_level: Overrides the Actor's permission level for this specific run. Use to test restricted permissions before deploying changes to your Actor or to temporarily elevate or restrict access. If you don't specify this parameter, the Actor uses its configured default permission level. For more information on permissions, see the documentation.

Request Body

Content Types: */*, application/json

list(actor_id, opts \\ [])

@spec list(actor_id :: String.t(), opts :: keyword()) ::
  {:ok, ApifyClient.Schemas.ListOfRuns.t()} | {:error, ApifyClient.Error.t()}

Get list of Actor's runs

Gets the list of runs of a specific Actor. The response is a list of objects, where each object contains basic information about a single Actor run.

The endpoint supports pagination using the limit and offset parameters and it will not return more than 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 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.

  • started_after: Filter runs that started after the specified date and time (inclusive). The value must be a valid ISO 8601 datetime string (UTC).

  • started_before: Filter runs that started before the specified date and time (inclusive). The value must be a valid ISO 8601 datetime string (UTC).

  • deployment: Single Actor Standby deployment or comma-separated list of deployments (SINGLE_TENANT, MULTI_TENANT_FREE_USERS, MULTI_TENANT_PAYING_USERS or MULTI_TENANT_OWNER_PAID). Used to filter Actor Standby runs by the pool that serves them. Requires the status parameter with only non-terminal statuses (READY, RUNNING, TIMING-OUT or ABORTING).

resurrect(actor_id, run_id, opts \\ [])

@spec resurrect(actor_id :: String.t(), run_id :: String.t(), opts :: keyword()) ::
  {:ok, ApifyClient.Schemas.Run.t()} | {:error, ApifyClient.Error.t()}

Resurrect Actor run

[DEPRECATED] API endpoints related to run of the Actor were moved under new namespace actor-runs (Manage Actor runs). Resurrects a finished Actor run and returns an object that contains all the details about the resurrected run.

Only finished runs, i.e. runs with status SUCCEEDED, FAILED, ABORTED and TIMED-OUT can be resurrected. Run status will be updated to RUNNING and its container will be restarted with the same storages (the same behaviour as when the run gets migrated to the new server).

For more information, see the Actor docs.

Options

  • build: Specifies the Actor build to run. It can be either a build tag or build number. By default, the run is resurrected with the same build it originally used. Specifically, if a run was first started with the latest tag, which resolves to version 0.0.3 at the time, a run resurrected without this parameter will continue running with 0.0.3, even if latest already points to a newer build.

  • timeout: Optional timeout for the run, in seconds. By default, the run uses the timeout specified in the run that is being resurrected.

  • memory: Memory limit for the run, in megabytes. The amount of memory can be set to a power of 2 with a minimum of 128. By default, the run uses the memory limit specified in the run that is being resurrected.

  • restart_on_error: Determines whether the resurrected run will be restarted if it fails. By default, the resurrected run uses the same setting as before.