Skip to content

docs: add missing actor-tasks endpoint #1510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apify-api/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,8 @@ paths:
$ref: 'paths/actor-tasks/actor-tasks@{actorTaskId}@run-sync.yaml'
'/v2/actor-tasks/{actorTaskId}/run-sync-get-dataset-items':
$ref: 'paths/actor-tasks/actor-tasks@{actorTaskId}@run-sync-get-dataset-items.yaml'
'/v2/actor-tasks/{actorTaskId}/runs/last':
$ref: 'paths/actor-tasks/actor-tasks@{actorTaskId}@[email protected]'
/v2/actor-runs:
$ref: paths/actor-runs/actor-runs.yaml
'/v2/actor-runs/{runId}':
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
get:
tags:
- Actor tasks
summary: Get last run
description: |
This is not a single endpoint, but an entire group of endpoints that lets you to
retrieve and manage the last run of given actor task or any of its default storages.
All the endpoints require an authentication token.
Comment on lines +6 to +8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not gonna lie, this is confusing. Can you spare the time to split this into four endpoints instead, each with their own documentation?

Of course, if that's something you want to pursue later, we can merge this as is - it sure is better than nothing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I fully agree. This is something that is next on TODO list, to split this and every other endpoint that is done this way into separate ones. This PR was meant to just reintroduce the missing endpoint so we have parity between old API Blueprint and current OpenAPI

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, right. I trust you to track that somewhere 🙂

Copy link
Contributor Author

@TC-MO TC-MO Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm not mistaken we have two like this already

Get last run
Get run

and this would be the third like that.


The endpoints accept the same HTTP methods and query parameters as
the respective storage endpoints.
The base path represents the last actor task run object is:

`/v2/actor-tasks/{actorTaskId}/runs/last{?token,status}`

Using the `status` query parameter you can ensure to only get a run with a certain status
(e.g. `status=SUCCEEDED`). The output of this endpoint and other query parameters
are the same as in the [Run object](/api/v2/actor-run-get) endpoint.

In order to access the default storages of the last actor task run, i.e. log, key-value store, dataset and request queue,
use the following endpoints:

* `/v2/actor-tasks/{actorTaskId}/runs/last/log{?token,status}`
* `/v2/actor-tasks/{actorTaskId}/runs/last/key-value-store{?token,status}`
* `/v2/actor-tasks/{actorTaskId}/runs/last/dataset{?token,status}`
* `/v2/actor-tasks/{actorTaskId}/runs/last/request-queue{?token,status}`

These API endpoints have the same usage as the equivalent storage endpoints.
For example,
`/v2/actor-tasks/{actorTaskId}/runs/last/key-value-store` has the same HTTP method and parameters as the
[Key-value store object](/api/v2/storage-key-value-stores) endpoint.

Additionally, each of the above API endpoints supports all sub-endpoints
of the original one:

##### Storage endpoints

* [Dataset - introduction](/api/v2/storage-datasets)

* [Key-value store - introduction](/api/v2/storage-key-value-stores)

* [Request queue - introduction](/api/v2/storage-request-queues)

For example, to download data from a dataset of the last succeeded actor task run in XML format,
send HTTP GET request to the following URL:

```
https://api.apify.com/v2/actor-tasks/{actorTaskId}/runs/last/dataset/items?token={yourApiToken}&format=xml&status=SUCCEEDED
```

In order to save new items to the dataset, send HTTP POST request with JSON payload to the same URL.
operationId: actorTask_runs_last_get
parameters:
- name: actorTaskId
in: path
description: Task ID or a tilde-separated owner's username and Actor task name.
required: true
style: simple
schema:
type: string
example: janedoe~my-task
- name: status
in: query
description: Filter for the run status.
style: form
explode: true
schema:
type: string
example: SUCCEEDED
responses:
'200':
description: ''
headers: {}
content:
application/json:
schema:
type: object
required:
- data
properties:
data:
$ref: "../../components/schemas/actor-runs/Run.yaml"
example:
data:
id: HG7ML7M8z78YcAPEB
actId: HDSasDasz78YcAPEB
userId: 7sT5jcggjjA9fNcxF
actorTaskId: KJHSKHausidyaJKHs
startedAt: '2019-11-30T07:34:24.202Z'
finishedAt: '2019-12-12T09:30:12.202Z'
status: RUNNING
statusMessage: Actor is running
isStatusMessageTerminal: false
meta:
origin: WEB
clientIp: 172.234.12.34
userAgent: Mozilla/5.0 (iPad)
stats:
inputBodyLen: 240
restartCount: 0
resurrectCount: 2
memAvgBytes: 267874071.9
memMaxBytes: 404713472
memCurrentBytes: 0
cpuAvgUsage: 33.75321011075384
cpuMaxUsage: 169.65073553494125
cpuCurrentUsage: 0
netRxBytes: 103508042
netTxBytes: 4854600
durationMillis: 248472
runTimeSecs: 248.472
metamorph: 0
computeUnits: 0.13804
options:
build: latest
timeoutSecs: 300
memoryMbytes: 1024
diskMbytes: 2048
buildId: 7sT5jcggjjA9fNcxF
exitCode: 0
defaultKeyValueStoreId: eJNzqsbPiopwJcgGQ
defaultDatasetId: wmKPijuyDnPZAPRMk
defaultRequestQueueId: FL35cSF7jrxr3BY39
buildNumber: 0.0.36
containerUrl: 'https://g8kd8kbc5ge8.runs.apify.net'
isContainerServerReady: true
gitBranchName: master
usage:
ACTOR_COMPUTE_UNITS: 3
DATASET_READS: 4
DATASET_WRITES: 4
KEY_VALUE_STORE_READS: 5
KEY_VALUE_STORE_WRITES: 3
KEY_VALUE_STORE_LISTS: 5
REQUEST_QUEUE_READS: 2
REQUEST_QUEUE_WRITES: 1
DATA_TRANSFER_INTERNAL_GBYTES: 1
DATA_TRANSFER_EXTERNAL_GBYTES?: 3
PROXY_RESIDENTIAL_TRANSFER_GBYTES: 34
PROXY_SERPS: 3
usageTotalUsd: 0.2654
usageUsd:
ACTOR_COMPUTE_UNITS: 0.072
DATASET_READS: 0.0004
DATASET_WRITES: 0.0002
KEY_VALUE_STORE_READS: 0.0006
KEY_VALUE_STORE_WRITES: 0.002
KEY_VALUE_STORE_LISTS: 0.004
REQUEST_QUEUE_READS: 0.005
REQUEST_QUEUE_WRITES: 0.02
DATA_TRANSFER_INTERNAL_GBYTES: 0.0004
DATA_TRANSFER_EXTERNAL_GBYTES?: 0.0002
PROXY_RESIDENTIAL_TRANSFER_GBYTES: 0.16
PROXY_SERPS: 0.0006
deprecated: false
x-legacy-doc-urls:
- https://docs.apify.com/api/v2#/reference/actor-tasks/last-run-object-and-its-storages