forked from apify/apify-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_v2_reference.apib
3160 lines (2290 loc) · 135 KB
/
api_v2_reference.apib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
FORMAT: 1A
HOST: https://api.apify.com/
# Apify API
The Apify API (version 2) is used to provide programmatic access to the [Apify platform](https://docs.apify.com).
The API is organized around [RESTful](https://en.wikipedia.org/wiki/Representational_state_transfer)
HTTP endpoints.
All requests and responses (including errors) are encoded in [JSON](http://www.json.org/) format with UTF-8 encoding,
with a few exceptions that are explicitly described in the reference.
To access the API from a Node.js code, we recommend using the
<a href="https://docs.apify.com/api/apify-client-js/latest">apify-client</a> NPM package.
**All requests with JSON payloads need to specify the `Content-Type: application/json` HTTP header!**
All API endpoints support the `method` query parameter that can override the HTTP method.
For example, if you want to call a POST endpoint using a GET request, simply
add the query parameter `method=POST` to the URL and send the GET request.
This feature is especially useful if you want to call Apify API endpoints
from services that can only send GET requests.
## Authentication
Most API requests need to be authenticated by passing a secret API token
to the request URL as the `token` query parameter.
The API token can be found on the
<a href="https://my.apify.com/account#/integrations" target="_blank" rel="nofollow">Integrations</a>
page in the Apify app.
**IMPORTANT: Do not share the API token with untrusted parties, or use it directly from a client-side code,
unless you fully understand the consequences!**
Note that some API endpoints such as [Get list of keys](#reference/key-value-stores/key-collection/get-list-of-keys)
do not require any authentication token, because they contain a hard-to-guess identifier that effectively serves as an authentication key.
## Response structure
Most API endpoints return a JSON object with the `data` property:
```
{
"data": {
...
}
}
```
However, there are a few explicitly described exceptions, such as
Dataset [Get items](#reference/datasets/item-collection/get-items) or
Key-value store [Get record](#reference/key-value-stores/record/get-record) API endpoints,
which return data in other formats.
In case of an error, the response has the HTTP status code in the range of 4xx or 5xx
and the `data` property is replaced with `error`. For example:
```
{
"error": {
"type": "record-not-found",
"message": "Store was not found."
}
}
```
See [Errors](#introduction/errors) for more details.
## Pagination
All API endpoints that return a list of records
(e.g. [Get list of actors](#reference/actors/actor-collection/get-list-of-actors))
enforce pagination in order to limit the size of their responses.
Most of these API endpoints are paginated using the `offset` and `limit` query parameters.
The only exception is [Get list of keys](#reference/key-value-stores/key-collection/get-list-of-keys),
which is paginated using the `exclusiveStartKey` query parameter.
**IMPORTANT**: Each API endpoint that supports pagination enforces a certain maximum value for the `limit` parameter,
in order to reduce the load on Apify servers.
The maximum limit could change in future so you should never
rely on a specific value and check the responses of these API endpoints.
### Using offset
Most API endpoints that return a list of records enable pagination using the following query parameters:
<table>
<tr>
<td><code>limit</code></td>
<td>Limits the response to contain a specific maximum number of items, e.g. <code>limit=20</code>.</td>
</tr>
<tr>
<td><code>offset</code></td>
<td>Skips a number of items from the beginning of the list, e.g. <code>offset=100</code>.</td>
</tr>
<tr>
<td><code>desc</code></td>
<td>By default, items are sorted in the order in which they were created or added to the list.
This feature is useful when fetching all the items, because it ensures that items
created after the client started the pagination will not be skipped.
If you specify the <code>desc=1</code> parameter, the items will be returned in the reverse order,
i.e. from the newest to the oldest items.
</td>
</tr>
</table>
The response of these API endpoints is always a JSON object with the following structure:
```
{
"data": {
"total": 2560,
"offset": 250,
"limit": 1000,
"count": 1000,
"desc": false,
"items": [
{ 1st object },
{ 2nd object },
...
{ 1000th object }
]
}
}
```
The following table describes the meaning of the response properties:
<table>
<tr>
<th>Property</th>
<th>Description</th>
</tr>
<tr>
<td><code>total</code></td>
<td>The total number of items available in the list.</td>
</tr>
<tr>
<td><code>offset</code></td>
<td>The number of items that were skipped at the start.
This is equal to the <code>offset</code> query parameter if it was provided, otherwise it is <code>0</code>.</td>
</tr>
<tr>
<td><code>limit</code></td>
<td>The maximum number of items that can be returned in the HTTP response.
It equals to the <code>limit</code> query parameter if it was provided or
the maximum limit enforced for the particular API endpoint, whichever is smaller.</td>
</tr>
<tr>
<td><code>count</code></td>
<td>The actual number of items returned in the HTTP response.</td>
</tr>
<tr>
<td><code>desc</code></td>
<td><code>true</code> if data were requested in descending order and <code>false</code> otherwise.</td>
</tr>
<tr>
<td><code>items</code></td>
<td>An array of requested items.</td>
</tr>
</table>
### Using key
The records in the <a href="https://docs.apify.com/storage/key-value-store" target="_blank" rel="noopener">Key-value store</a>
are not ordered based on numerical indexes,
but rather by their keys in the UTF-8 binary order.
Therefore the [Get list of keys](#reference/key-value-stores/key-collection/get-list-of-keys)
API endpoint only supports pagination using the following query parameters:
<table>
<tr>
<td><code>limit</code></td>
<td>Limits the response to contain a specific maximum number items, e.g. <code>limit=20</code>.</td>
</tr>
<tr>
<td><code>exclusiveStartKey</code></td>
<td>Skips all records with keys up to the given key including the given key,
in the UTF-8 binary order.</td>
</tr>
</table>
The response of the API endpoint is always a JSON object with following structure:
```
{
"data": {
"limit": 1000,
"isTruncated": true,
"exclusiveStartKey": "my-key",
"nextExclusiveStartKey": "some-other-key",
"items": [
{ 1st object },
{ 2nd object },
...
{ 1000th object }
]
}
}
```
The following table describes the meaning of the response properties:
<table>
<tr>
<th>Property</th>
<th>Description</th>
</tr>
<tr>
<td><code>limit</code></td>
<td>The maximum number of items that can be returned in the HTTP response.
It equals to the <code>limit</code> query parameter if it was provided or
the maximum limit enforced for the particular endpoint, whichever is smaller.</td>
</tr>
<tr>
<td><code>isTruncated</code></td>
<td><code>true</code> if there are more items left to be queried. Otherwise <code>false</code>.</td>
</tr>
<tr>
<td><code>exclusiveStartKey</code></td>
<td>The last key that was skipped at the start. Is `null` for the first page.</td>
</tr>
<tr>
<td><code>nextExclusiveStartKey</code></td>
<td>The value for the <code>exclusiveStartKey</code> parameter to query the next page of items.</td>
</tr>
</table>
## Errors
The Apify API uses common HTTP status codes: `2xx` range for success, `4xx` range for errors caused by the caller
(invalid requests) and `5xx` range for server errors (these are rare).
Each error response contains a JSON object defining the `error` property, which is an object with
the `type` and `message` properties that contain the error code and a human-readable error description, respectively.
For example:
````
{
"error": {
"type": "record-not-found",
"message": "Store was not found."
}
}
````
Here is the table of the most common errors that can occur for many API endpoints:
<table>
<tr>
<th>status</th>
<th>type</th>
<th>message</th>
</tr>
<tr>
<td><code>400</code></td>
<td><code>invalid-request</code></td>
<td>POST data must be a JSON object</td>
</tr>
<tr>
<td><code>400</code></td>
<td><code>invalid-value</code></td>
<td>Invalid value provided: Comments is required</td>
</tr>
<tr>
<td><code>400</code></td>
<td><code>invalid-record-key</code></td>
<td>Record key contains invalid character</td>
</tr>
<tr>
<td><code>401</code></td>
<td><code>token-not-provided</code></td>
<td>Authentication token was not provided</td>
</tr>
<tr>
<td><code>404</code></td>
<td><code>record-not-found</code></td>
<td>Store was not found</td>
</tr>
<tr>
<td><code>429</code></td>
<td><code>rate-limit-exceeded</code></td>
<td>You have exceeded the rate limit of 20 requests per second</td>
</tr>
<tr>
<td><code>405</code></td>
<td><code>method-not-allowed</code></td>
<td>This API endpoint can only be accessed using the following HTTP methods: OPTIONS, POST</td>
</tr>
</table>
## Rate limiting
All API endpoints limit the rate of requests in order to prevent overloading of Apify servers by misbehaving clients.
The default rate limit is 30 requests per second and is applied to every API endpoint except the following list
of endpoints that are rate limited to 200 requests per second:
* [Run actor](#reference/actors/run-collection/run-actor)
* [Run actor task asynchronously](#reference/actor-tasks/runs-collection/run-task-asynchronously)
* [Run actor task synchronously](#reference/actor-tasks/runs-collection/run-task-synchronously)
* [Metamorph actor run](#reference/actors/metamorph-run/metamorph-run)
* [Push items](#reference/datasets/item-collection/put-items) to dataset
* CRUD
([add](#reference/request-queues/request-collection/add-request),
[get](#reference/request-queues/request-collection/get-request),
[update](#reference/request-queues/request-collection/update-request),
[delete](#reference/request-queues/request-collection/delete-request))
operations of request queue requests
For authenticated API endpoints, the limit is counted per user,
storage API endpoints count the limit per storage object
and anonymous API endpoints per IP address of the client.
If the client is sending too many requests, the API endpoints respond with the HTTP status code `429 Too Many Requests`
and the following body:
````
{
"error": {
"type": "rate-limit-exceeded",
"message": "You have exceeded the rate limit of 20 requests per second"
}
}
````
If the client receives the rate limit error, it should wait a certain period of time and then retry the request.
If the error happens again, the client should double the wait period and retry the request,
and so on. This algorithm is known as _exponential backoff_
and it can be described using the following pseudo-code:
1. Define a variable `DELAY=500`
2. Send the HTTP request to the API endpoint
3. If the response has status code not equal to `429` then you are done. Otherwise:
* Wait for a period of time chosen randomly from the interval `DELAY` to `2*DELAY` milliseconds
* Double the future wait period by setting `DELAY = 2*DELAY`
* Continue with step 2
If all requests sent by the client implement the above steps,
the client will automatically use the maximum available bandwidth for its requests.
Note that the <a href="https://docs.apify.com/api/apify-client-js/latest">apify-client</a> NPM package
uses the exponential backoff algorithm transparently, so that you do not need to worry about it.
# Group Actors
The API endpoints described in this section enable you to manage, build and run Apify actors.
For more information, see the <a href="https://docs.apify.com/actor">Actor documentation</a>.
Note that for all the API endpoints that accept the `actorId` parameter to specify an actor,
you can pass either the actor ID (e.g. `HG7ML7M8z78YcAPEB`) or a tilde-separated
username of the actor owner and the actor name (e.g. `johndoe~my-actor`).
## Actor collection [/v2/acts{?token,offset,limit,desc,my}]
+ Parameters
+ token: `rWLaYmvZeK55uatRrZib4xbZs` (string, required) - API authentication token.
+ my: false (boolean, optional) - If true returns only own actors. By default returns all the actors used by the user.
### Get list of actors [GET]
Gets the list of all actors that the user created or used. The response is a list of objects where each object
contains a basic information about a single actor.
To only get actors created by the user, add the `my=1` query parameter.
The endpoint supports pagination using the `limit` and `offset` parameters and it will not return more than 1000 records.
By default, the records are sorted by the `createdAt` field in ascending order,
therefore you can use pagination to incrementally fetch all actors while new
ones are still being created. To sort the records in descending order, use the `desc=1`
parameter.
+ Parameters
+ my: true (boolean, optional) - If `true` or `1` then the returned list only contains actors owned by the user. The default value is `false`.
+ offset: 10 (number, optional) - Number of records that should be skipped at the start. The default value is `0`.
+ limit: 99 (number, optional) - Maximum number of records to return. The default value as well as the maximum is `1000`.
+ desc: true (boolean, optional) - If `true` or `1` then the objects are sorted by the `createdAt` field in descending order. By default, they are sorted in ascending order.
+ Response 200 (application/json)
+ Attributes
- data (object, required)
- total: 2 (number, required)
- offset: 0 (number, required)
- limit: 1000 (number, required)
- desc: false (boolean, required)
- count: 2 (number, required)
- items (array[ActorShort1,ActorShort2], required)
### Create actor [POST]
Creates a new actor with settings specified in an Actor object passed as JSON in the POST payload.
The response is the full actor object as returned by the
[Get actor](#reference/actors/actor-object/get-actor) endpoint.
The HTTP request must have the `Content-Type: application/json` HTTP header!
The actor needs to define at least one version of the source code.
For more information, see [Version object](#reference/actors/version-object).
+ Request (application/json)
+ Attributes(ActCreate)
+ Response 201 (application/json)
+ Headers
Location: https://api.apify.com/v2/acts/zdc3Pyhyz3m8vjDeM
+ Attributes
- data (Actor, required)
## Actor object [/v2/acts/{actorId}{?token}]
+ Parameters
+ actorId: `johndoe~my-actor` (string, required) - Actor ID or a tilde-separated owner's username and actor name.
+ token: `rWLaYmvZeK55uatRrZib4xbZs` (string, required) - API authentication token.
### Get actor [GET]
Gets an object that contains all the details about a specific actor.
+ Response 200 (application/json)
+ Attributes
- data (Actor, required)
### Update actor [PUT]
Updates settings of an actor using values specified by an actor object passed as JSON in the POST payload.
If the object does not define a specific property, its value will not be updated.
The response is the full actor object as returned by the
[Get actor](#reference/actors/actor-object/get-actor) endpoint.
The request needs to specify the `Content-Type: application/json` HTTP header!
+ Request (application/json)
+ Attributes(ActUpdate)
+ Response 200 (application/json)
+ Attributes
- data (Actor, required)
### Delete actor [DELETE]
Deletes an actor.
+ Response 204 (application/json)
+ Attributes(object)
## Version collection [/v2/acts/{actorId}/versions{?token}]
+ Parameters
+ actorId: `johndoe~my-actor` (string, required) - Actor ID or a tilde-separated owner's username and actor name.
+ token: `rWLaYmvZeK55uatRrZib4xbZs` (string, required) - API authentication token.
### Get list of versions [GET]
Gets the list of versions of a specific actor. The response is a JSON with the list
of [Version objects](#reference/actors/version-object) where each
contains basic information about a single version.
+ Response 200 (application/json)
+ Attributes
- data (object, required)
- total: 1 (number, required)
- items (array[Version], required)
### Create version [POST]
Creates an actor version using values specified by a [Version object](#reference/actors/version-object) passed as JSON in the POST payload.
The request needs to specify the `Content-Type: application/json` HTTP header!
The response is the [Version object](#reference/actors/version-object) as returned by the
[Get version](#reference/actors/version-object/get-version) endpoint.
+ Attributes(VersionUpdate)
+ Response 201 (application/json)
+ Headers
Location: https://api.apify.com/v2/acts/zdc3Pyhyz3m8vjDeM/versions/0.0
+ Attributes
- data (Version, required)
## Version object [/v2/acts/{actorId}/versions/{versionNumber}{?token}]
The **Version object** contains the source code of a specific version of an actor.
The `sourceType` field indicates where the source code is hosted, and based
on its value the Version object has the following additional fields:
<table>
<tr>
<td><code>"SOURCE_CODE"</code></td>
<td>
Source code is a single JavaScript/Node.js file whose content is in the <code>sourceCode</code> field,
and uses a base Docker image specified in <code>baseDockerImage</code>.
</td>
</tr>
<tr>
<td><code>"SOURCE_FILES"</code></td>
<td>
Source code is comprised of multiple files specified in the <code>sourceFiles</code> array.
Each item of the array is an object with the following fields:<br>
<code>name</code></li> - File path and name<br>
<code>format</code></li> - Format of the content, can be either <code>"TEXT"</code> or <code>"BASE64"</code><br>
<code>content</code></li> - File content
</td>
</tr>
<tr>
<td><code>"GIT_REPO"</code></td>
<td>
Source code is cloned from a Git repository, whose URL is specified in the <code>gitRepoUrl</code> field.
</td>
</tr>
<tr>
<td><code>"TARBALL"</code></td>
<td>
Source code is downloaded using a tarball or Zip file from a URL specified in the <code>tarballUrl</code> field.
</td>
</tr>
<tr>
<td><code>"GITHUB_GIST"</code></td>
<td>
Source code is taken from a GitHub Gist, whose URL is specified in the <code>gitHubGistUrl</code> field.
</td>
</tr>
</table>
For more information about source code and actor versions, see [Source code](https://docs.apify.com/actor/source-code) in Actors documentation.
+ Parameters
+ actorId: `johndoe~my-actor` (string, required) - Actor ID or a tilde-separated owner's username and actor name.
+ versionNumber: `1.0` (string, required) - Actor major and minor version of the actor.
+ token: `rWLaYmvZeK55uatRrZib4xbZs` (string, required) - API authentication token.
### Get version [GET]
Gets a [Version object](#reference/actors/version-object) that contains all the details about a specific version of an actor.
+ Response 200 (application/json)
+ Attributes
- data (Version, required)
### Update version [PUT]
Updates actor version using values specified by a [Version object](#reference/actors/version-object)
passed as JSON in the POST payload.
If the object does not define a specific property, its value will not be updated.
The request needs to specify the `Content-Type: application/json` HTTP header!
The response is the [Version object](#reference/actors/version-object) as returned by the
[Get version](#reference/actors/version-object/get-version) endpoint.
+ Request (application/json)
+ Attributes(VersionUpdate)
+ Response 200 (application/json)
+ Attributes
- data (Version, required)
### Delete version [DELETE]
Deletes a specific version of actor's source code.
+ Response 204 (application/json)
+ Attributes(object)
## Webhook collection [/v2/acts/{actorId}/webhooks{?token,offset,limit,desc}]
+ Parameters
+ actorId: `johndoe~my-actor` (string, required) - Actor ID or a tilde-separated owner's username and actor name.
+ token: `rWLaYmvZeK55uatRrZib4xbZs` (string, required) - API authentication token.
### Get list of webhooks [GET]
Gets the list of webhooks of a specific actor. The response is a JSON with the list of objects where each object
contains basic information about a single webhook.
The endpoint supports pagination using the `limit` and `offset` parameters and it will not return more than 1000 records.
By default, the records are sorted by the `createdAt` field in ascending order,
to sort the records in descending order, use the `desc=1` parameter.
+ Parameters
+ token: `rWLaYmvZeK55uatRrZib4xbZs` (string, required) - API authentication token.
+ offset: 10 (number, optional) - Number of array elements that should be skipped at the start. The default value is `0`.
+ limit: 99 (number, optional) - Maximum number of array elements to return. The default value as well as the maximum is `1000`.
+ desc: true (boolean, optional) - If `true` or `1` then the objects are sorted by the `createdAt` field in descending order. By default, they are sorted in ascending order.
+ Response 200 (application/json)
+ Attributes
- data (object, required)
- total: 2 (number, required)
- offset: 0 (number, required)
- limit: 1000 (number, required)
- desc: false (boolean, required)
- count: 2 (number, required)
- items (array[Webhook,Webhook], required)
## Build collection [/v2/acts/{actorId}/builds{?token,offset,limit,desc,waitForFinish,version,useCache,betaPackages,tag}]
+ Parameters
+ actorId: `johndoe~my-actor` (string, required) - Actor ID or a tilde-separated owner's username and actor name.
+ token: `rWLaYmvZeK55uatRrZib4xbZs` (string, required) - API authentication token.
### Get list of builds [GET]
Gets the list of builds of a specific actor. The response is a JSON with the list of objects where each object
contains basic information about a single build.
The endpoint supports pagination using the `limit` and `offset` parameters and it will not return more than 1000 records.
By default, the records are sorted by the `startedAt` field in ascending order,
therefore you can use pagination to incrementally fetch all builds while new
ones are still being started. To sort the records in descending order, use the `desc=1`
parameter.
+ Parameters
+ offset: 10 (number, optional) - Number of records that should be skipped at the start. The default value is `0`.
+ limit: 99 (number, optional) - Maximum number of records to return. The default value as well as the maximum is `1000`.
+ desc: true (boolean, optional) - If `true` or `1` then the objects are sorted by the `startedAt` field in descending order. By default, they are sorted in ascending order.
+ Response 200 (application/json)
+ Attributes
- data (object, required)
- total: 2 (number, required)
- offset: 0 (number, required)
- limit: 1000 (number, required)
- desc: false (boolean, required)
- count: 2 (number, required)
- items (array[BuildShort1,BuildShort2], required)
### Build actor [POST]
Builds an actor.
The response is the build object as returned by the
[Get build](#reference/actors/build-object/get-build) endpoint.
+ Parameters
+ version: `0.0` (string, required) - Actor version number to be built.
+ useCache: true (boolean, optional) - If `true` or `1`, the system will use a cache to speed up the build process. By default, cache is not used.
+ betaPackages: true (boolean, optional) - If `true` or `1` then the actor is built with beta versions of Apify NPM packages. By default, the build uses `latest` packages.
+ tag: `latest` (string, optional) - Tag to be applied to the build on success. By default, the tag is taken from actor version's `buildTag` property.
+ waitForFinish: 60 (number, optional) - The maximum number of seconds the server waits for the build to finish. By default it is `0`, the maximum value is `300`. <!-- MAX_ACTOR_JOB_SYNC_WAIT_SECS -->
If the build finishes in time then the returned build object will have a terminal status (e.g. `SUCCEEDED`),
otherwise it will have a transitional status (e.g. `RUNNING`).
+ Response 201 (application/json)
+ Headers
Location: https://api.apify.com/v2/acts/zdc3Pyhyz3m8vjDeM/runs/HG7ML7M8z78YcAPEB
+ Attributes
- data (Build, required)
## Build object [/v2/acts/{actorId}/builds/{buildId}{?token,waitForFinish}]
+ Parameters
+ actorId: `johndoe~my-actor` (string, required) - Actor ID or a tilde-separated owner's username and actor name.
### Get build [GET]
Gets an object that contains all the details about a specific build of an actor.
By passing the optional `waitForFinish=1` parameter the API endpoint will synchronously wait for the build to finish.
This is useful to avoid periodic polling when waiting for an actor build to finish.
+ Parameters
+ waitForFinish: 60 (number, optional) - The maximum number of seconds the server waits for the build to finish. By default it is `0`, the maximum value is `300`. <!-- MAX_ACTOR_JOB_SYNC_WAIT_SECS -->
If the build finishes in time then the returned build object will have a terminal status (e.g. `SUCCEEDED`),
otherwise it will have a transitional status (e.g. `RUNNING`).
+ token: `rWLaYmvZeK55uatRrZib4xbZs` (string, optional) - API authentication token. It is only required for private actors.
Builds of public actors can be queried without any token.
+ Response 200 (application/json)
+ Attributes
- data (Build, required)
## Abort build [/v2/acts/{actorId}/builds/{buildId}/abort{?token}]
### Abort build [POST]
Aborts an actor build and returns an object that contains all the details about the build.
Only builds that are starting or running are aborted. For builds with status `FINISHED`, `FAILED`, `ABORTING` and `TIMED-OUT` this call does nothing.
+ Parameters
+ actorId: `johndoe~my-actor` (string, required) - Actor ID or a tilde-separated owner's username and actor name.
+ buildId: `3KH8gEpp4d8uQSe8T` (string, required) - Build ID.
+ token: `rWLaYmvZeK55uatRrZib4xbZs` (string, required) - API authentication token.
+ Response 200 (application/json)
+ Attributes
- data (BuildAborted, required)
## Run collection [/v2/acts/{actorId}/runs{?token,offset,limit,desc,waitForFinish,timeout,memory,build,webhooks}]
+ Parameters
+ actorId: `johndoe~my-actor` (string, required) - Actor ID or a tilde-separated owner's username and actor name.
### Get list of runs [GET]
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.
+ Parameters
+ token: `rWLaYmvZeK55uatRrZib4xbZs` (string, required) - API authentication token.
+ offset: 10 (number, optional) - Number of array elements that should be skipped at the start. The default value is `0`.
+ limit: 99 (number, optional) - Maximum number of array elements to return. The default value as well as the maximum is `1000`.
+ desc: true (boolean, optional) - If `true` or `1` then the objects are sorted by the `startedAt` field in descending order. By default, they are sorted in ascending order.
+ Response 200 (application/json)
+ Attributes
- data (object, required)
- total: 2 (number, required)
- offset: 0 (number, required)
- limit: 1000 (number, required)
- desc: false (boolean, required)
- count: 2 (number, required)
- items (array[RunShort1,RunShort2], required)
### Run actor [POST]
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 <code>application/json</code>).
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 run](#reference/actors/run-object/get-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 one of the [Run actor synchronously](#reference/actors/run-actor-synchronously) API endpoints 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 items](#reference/datasets/item-collection/get-items) API endpoint.
+ Parameters
+ token: `rWLaYmvZeK55uatRrZib4xbZs` (string, optional) - API authentication token. Public actors that are configured to be anonymously runnable do not require the token.
+ timeout: 60 (number, optional) - Optional timeout for the run, in seconds. By default, the run uses a timeout specified in the default run configuration for the actor.
+ memory: 256 (number, optional) - Memory limit for the run, in megabytes. By default, the run uses a memory limit specified in the default run configuration for the actor.
+ build: `0.1.234` (string, optional) - Specifies the actor build to run. It can be either a build tag or build number. By default, the run uses the build specified in the default run configuration for the actor (typically `latest`).
+ waitForFinish: 60 (number, optional) - The maximum number of seconds the server waits for the run to finish. By default, it is `0`, the maximum value is `300`. <!-- MAX_ACTOR_JOB_SYNC_WAIT_SECS -->
If the build 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: `dGhpcyBpcyBqdXN0IGV4YW1wbGUK...` (string, optional) - 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 of objects defining the webhooks. For more information, see
[Webhooks documenation](https://docs.apify.com/webhooks).
+ Request
+ Headers
Content-Type: application/json
+ Attributes
- foo: `bar`
+ Response 201 (application/json)
+ Headers
Location: https://api.apify.com/v2/acts/zdc3Pyhyz3m8vjDeM/runs/HG7ML7M8z78YcAPEB
+ Attributes
- data (Run, required)
## Run actor synchronously [/v2/acts/{actorId}/run-sync{?token,outputRecordKey,timeout,memory,build,webhooks}]
+ Parameters
+ actorId: `johndoe~my-actor` (string, required) - Actor ID or a tilde-separated owner's username and actor name.
+ token: `rWLaYmvZeK55uatRrZib4xbZs` (string, optional) - API authentication token. Public actors that are configured to be anonymously runnable do not require token parameter.
+ outputRecordKey: `OUTPUT` (string, optional) - Key of the record from run's default key-value store to be returned
in the response. By default, it is `OUTPUT`.
+ timeout: 60 (number, optional) - Optional timeout for the run, in seconds. By default, the run uses a timeout specified in the default run configuration for the actor.
+ memory: 256 (number, optional) - Memory limit for the run, in megabytes. By default, the run uses a memory limit specified in the default run configuration for the actor.
+ build: `0.1.234` (string, optional) - Specifies the actor build to run. It can be either a build tag or build number. By default, the run uses the build specified in the default run configuration for the actor (typically `latest`).
+ webhooks: `dGhpcyBpcyBqdXN0IGV4YW1wbGUK...` (string, optional) - 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 of objects defining the webhooks. For more information, see
[Webhooks documenation](https://docs.apify.com/webhooks).
### With input [POST]
Runs a specific actor and returns its output.
The POST payload including its `Content-Type` header is passed as `INPUT` to the actor (usually <code>application/json</code>).
The HTTP response contains actor's `OUTPUT` record from its default key-value store.
The actor is started with the default options; you can override them using various URL query parameters.
If the actor run exceeds 300<!-- MAX_ACTOR_JOB_SYNC_WAIT_SECS --> seconds,
the HTTP response will have status 408 (Request Timeout).
Beware that it might be impossible to maintain an idle HTTP connection for a long period of time,
due to client timeout or network conditions. Make sure your HTTP client is configured to have a long enough connection timeout.
If the connection breaks, you will not receive any information about the run and its status.
To run the actor asynchronously, use the [Run actor](#reference/actors/run-collection/run-actor) API endpoint instead.
+ Request
+ Headers
Content-Type: application/json
+ Attributes
- foo: `bar`
+ Response 201
+ Headers
Content-Type: application/json
+ Attributes
- bar: `foo`
+ Response 400
+ Headers
Content-Type: application/json
+ Attributes
- error (object, required)
- type: `run-failed` (string, required)
- message: `Actor run did not succeed (run ID: 55uatRrZib4xbZs, status: FAILED)` (string, required)
+ Response 408
+ Headers
Content-Type: application/json
+ Attributes
- error (object, required)
- type: `run-timeout-exceeded` (string, required)
- message: `Actor run exceeded timeout of 300 seconds for this API endpoint` (string, required)
### Without input [GET]
Runs a specific actor and returns its output.
The run must finish in 300<!-- MAX_ACTOR_JOB_SYNC_WAIT_SECS --> seconds otherwise the API endpoint returns a timeout error.
The actor is not passed any input.
Beware that it might be impossible to maintain an idle HTTP connection for a long period of time,
due to client timeout or network conditions. Make sure your HTTP client is configured to have a long enough connection timeout.
If the connection breaks, you will not receive any information about the run and its status.
To run the actor asynchronously, use the [Run actor](#reference/actors/run-collection/run-actor) API endpoint instead.
+ Response 201
+ Headers
Content-Type: application/json
+ Attributes
- foo: `bar`
+ Response 400
+ Headers
Content-Type: application/json
+ Attributes
- error (object, required)
- type: `run-failed` (string, required)
- message: `Actor run did not succeed (run ID: 55uatRrZib4xbZs, status: FAILED)` (string, required)
+ Response 408
+ Headers
Content-Type: application/json
+ Attributes
- error (object, required)
- type: `run-timeout-exceeded` (string, required)
- message: `Actor run exceeded timeout of 60 seconds for this API enpoint` (string, required)
## Run object [/v2/acts/{actorId}/runs/{runId}{?token,waitForFinish}]
### Get run [GET]
Gets an object that contains all the details about a specific run of an actor.
By passing the optional `waitForFinish=1` parameter the API endpoint will synchronously wait for the build to finish.
This is useful to avoid periodic polling when waiting for actor build to complete.
This endpoints do not require the authentication token, the calls are authenticated using a hard-to-guess ID of the run.
+ Parameters
+ actorId: `johndoe~my-actor` (string, required) - Actor ID or a tilde-separated owner's username and actor name.
+ runId: `3KH8gEpp4d8uQSe8T` (string, required) - Run ID.
+ waitForFinish: 60 (number, optional) - The maximum number of seconds the server waits for the run to finish. By default it is `0`, the maximum value is `300`. <!-- MAX_ACTOR_JOB_SYNC_WAIT_SECS -->
If the build 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`).
+ Response 200 (application/json)
+ Attributes
- data (Run, required)
## Abort run [/v2/acts/{actorId}/runs/{runId}/abort{?token}]
### Abort run [POST]
Aborts an actor run and returns an object that contains all the details about the run.
Only runs that are starting or running are aborted. For runs with status `FINISHED`, `FAILED`, `ABORTING` and `TIMED-OUT` this call does nothing.
+ Parameters
+ actorId: `johndoe~my-actor` (string, required) - Actor ID or a tilde-separated owner's username and actor name.
+ runId: `3KH8gEpp4d8uQSe8T` (string, required) - Run ID.
+ token: `rWLaYmvZeK55uatRrZib4xbZs` (string, required) - API authentication token.
+ Response 200 (application/json)
+ Attributes
- data (RunAborted, required)
## Metamorph run [/v2/acts/{actorId}/runs/{runId}/metamorph{?token,build,targetActorId}]
### Metamorph run [POST]
Transforms an actor run into a run of another actor with a new input.
This is useful if you want to use another actor to finish the work
of your current actor run, without the need to create a completely new run and waiting for its finish.
For the users of your actors, the metamorph operation is transparent, they will just see your actor got the work done.
Internally, the system stops the Docker container corresponding to the actor run
and starts a new container using a different Docker image.
All the default storages are preserved and the new input is stored under the `INPUT-METAMORPH-1` key in the same default key-value store.
For more information, see [Actor docs](http://apify.com/docs/actor#metamorph).
+ Parameters
+ actorId: `johndoe~my-actor` (string, required) - Actor ID or a tilde-separated owner's username and actor name.
+ runId: `3KH8gEpp4d8uQSe8T` (string, required) - Actor run ID.
+ token: `rWLaYmvZeK55uatRrZib4xbZs` (string, required) - API authentication token.
+ targetActorId: `HDSasDasz78YcAPEB` (string, required) - ID of a target actor that the run should be transformed into.
+ build: `beta` (string, optional) - Optional build of the target actor.
It can be either a build tag or build number. By default, the run uses the build specified in the default run configuration for the target actor (typically `latest`).