Apify API client for JavaScript
npm install @adactiveasia/apify-clientfork from apify client for javascript
fixing error on build
apify-client is the official library to access Apify API from your- Quick Start
- Features
* Automatic parsing and error handling
* Retries with exponential backoff
* Convenience functions and options
- Usage concepts
* Nested clients
* Pagination
- API Reference
js
const ApifyClient = require('apify-client');const client = new ApifyClient({
token: 'MY-APIFY-TOKEN',
});
// Starts an actor and waits for it to finish.
const { defaultDatasetId } = await client.actor('john-doe/my-cool-actor').call();
// Fetches results from the actor's dataset.
const { items } = await client.dataset(defaultDatasetId).listItems();
`Features
Besides greatly simplifying the process of querying the Apify API, the client provides other useful features.$3
Based on the endpoint, the client automatically extracts the relevant data and returns it in the
expected format. Date strings are automatically converted to Date objects. For exceptions,
we throw an ApifyApiError, which wraps the plain JSON errors returned by API and enriches
them with other context for easier debugging.$3
Network communication sometimes fails, that's a given. The client will automatically retry requests that
failed due to a network error, an internal error of the Apify API (HTTP 500+) or rate limit error (HTTP 429).
By default, it will retry up to 8 times. First retry will be attempted after ~500ms, second after ~1000ms
and so on. You can configure those parameters using the maxRetries and minDelayBetweenRetriesMillis
options of the ApifyClient constructor.$3
Some actions can't be performed by the API itself, such as indefinite waiting for an actor run to finish
(because of network timeouts). The client provides convenient call() and waitForFinish() functions that do that.
Key-value store records can be retrieved as objects, buffers or streams via the respective options, dataset items
can be fetched as individual objects or serialized data and we plan to add better stream support and async iterators.Usage concepts
The ApifyClient interface follows a generic pattern that is applicable to all of its components.
By calling individual methods of ApifyClient, specific clients which target individual API
resources are created. There are two types of those clients. A client for management of a single
resource and a client for a collection of resources.`js
const ApifyClient = require('apify-client');
const apifyClient = new ApifyClient({ token: 'my-token' });// Collection clients do not require a parameter.
const actorCollectionClient = apifyClient.actors();
// Creates an actor with the name: my-actor.
const myActor = await actorCollectionClient.create({ name: 'my-actor' });
// Lists all of your actors.
const { items } = await actorCollectionClient.list();
``js
// Collection clients do not require a parameter.
const datasetCollectionClient = apifyClient.datasets();
// Gets (or creates, if it doesn't exist) a dataset with the name of my-dataset.
const myDataset = await datasetCollectionClient.getOrCreate('my-dataset');
``js
// Resource clients accept an ID of the resource.
const actorClient = apifyClient.actor('john-doe/my-actor');
// Fetches the john-doe/my-actor object from the API.
const myActor = await actorClient.get();
// Starts the run of john-doe/my-actor and returns the Run object.
const myActorRun = await actorClient.start();
``js
// Resource clients accept an ID of the resource.
const datasetClient = apifyClient.dataset('john-doe/my-dataset');
// Appends items to the end of john-doe/my-dataset.
await datasetClient.pushItems([{ foo: 1 }, { bar: 2 }]);
`> The ID of the resource can be either the
id of the said resource,
> or a combination of your username/resource-name.This is really all you need to remember, because all resource clients
follow the pattern you see above.
$3
Sometimes clients return other clients. That's to simplify working with
nested collections, such as runs of a given actor.`js
const actorClient = apifyClient.actor('john-doe/hello-world');
const runsClient = actorClient.runs();
// Lists the last 10 runs of the john-doe/hello-world actor.
const { items } = await runsClient.list({ limit: 10, desc: true })// Selects the last run of the john-doe/hello-world actor that finished
// with a SUCCEEDED status.
const lastSucceededRunClient = actorClient.lastRun({ status: 'SUCCEEDED' });
// Fetches items from the run's dataset.
const { items } = await lastSucceededRunClient.dataset().listItems();
`> The quick access to
dataset and other storages directly from the run
> client can now only be used with the lastRun() method, but the feature
> will be available to all runs in the future.$3
Most methods named list or listSomething return a Promise.<PaginationList>.
There are some exceptions though, like listKeys or listHead which paginate differently.
The results you're looking for are always stored under items and you can use the limit
property to get only a subset of results. Other props are also available, depending on the method.API Reference
All public classes, methods and their parameters can be inspected in this API reference.$3
ApifyClient is the official library to access Apify API from your
JavaScript applications. It runs both in Node.js and browser.
* ApifyClient
* [
new ApifyClient([options])](#new_ApifyClient_new)
* .actors() ⇒ ActorCollectionClient
* .actor(id) ⇒ ActorClient
* .build(id) ⇒ BuildClient
* .datasets() ⇒ DatasetCollectionClient
* .dataset(id) ⇒ DatasetClient
* .keyValueStores() ⇒ KeyValueStoreCollectionClient
* .keyValueStore(id) ⇒ KeyValueStoreClient
* .log(buildOrRunId) ⇒ LogClient
* .requestQueues() ⇒ RequestQueueCollection
* [.requestQueue(id, [options])](#ApifyClient+requestQueue) ⇒ RequestQueueClient
* .run(id) ⇒ RunClient
* .tasks() ⇒ TaskCollectionClient
* .task(id) ⇒ TaskClient
* .schedules() ⇒ ScheduleCollectionClient
* .schedule(id) ⇒ ScheduleClient
* .user(id) ⇒ UserClient
* .webhooks() ⇒ WebhookCollectionClient
* .webhook(id) ⇒ WebhookClient
* .webhookDispatches() ⇒ WebhookDispatchCollectionClient
* .webhookDispatch(id) ⇒ WebhookDispatchClient
*
#### [](#ApifyClient)
new ApifyClient([options])
| Param | Type | Default |
| --- | --- | --- |
| [options] | object | |
| [options.baseUrl] | string | "https://api.apify.com" |
| [options.maxRetries] | number | 8 |
| [options.minDelayBetweenRetriesMillis] | number | 500 |
| [options.requestInterceptors] | Array.<function()> | |
| [options.timeoutSecs] | number | |
| [options.token] | string | |
*
#### [](#ApifyClient+actors)
apifyClient.actors() ⇒ ActorCollectionClienthttps://docs.apify.com/api/v2#/reference/actors/actor-collection
*
#### [](#ApifyClient+actor)
apifyClient.actor(id) ⇒ ActorClienthttps://docs.apify.com/api/v2#/reference/actors/actor-object
| Param | Type |
| --- | --- |
| id | string |
*
#### [](#ApifyClient+build)
apifyClient.build(id) ⇒ BuildClienthttps://docs.apify.com/api/v2#/reference/actor-builds/build-object
| Param | Type |
| --- | --- |
| id | string |
*
#### [](#ApifyClient+datasets)
apifyClient.datasets() ⇒ DatasetCollectionClienthttps://docs.apify.com/api/v2#/reference/datasets/dataset-collection
*
#### [](#ApifyClient+dataset)
apifyClient.dataset(id) ⇒ DatasetClienthttps://docs.apify.com/api/v2#/reference/datasets/dataset
| Param | Type |
| --- | --- |
| id | string |
*
#### [](#ApifyClient+keyValueStores)
apifyClient.keyValueStores() ⇒ KeyValueStoreCollectionClienthttps://docs.apify.com/api/v2#/reference/key-value-stores/store-collection
*
#### [](#ApifyClient+keyValueStore)
apifyClient.keyValueStore(id) ⇒ KeyValueStoreClienthttps://docs.apify.com/api/v2#/reference/key-value-stores/store-object
| Param | Type |
| --- | --- |
| id | string |
*
#### [](#ApifyClient+log)
apifyClient.log(buildOrRunId) ⇒ LogClienthttps://docs.apify.com/api/v2#/reference/logs
| Param | Type |
| --- | --- |
| buildOrRunId | string |
*
#### [](#ApifyClient+requestQueues)
apifyClient.requestQueues() ⇒ RequestQueueCollectionhttps://docs.apify.com/api/v2#/reference/request-queues/queue-collection
*
#### [](#ApifyClient+requestQueue)
apifyClient.requestQueue(id, [options]) ⇒ RequestQueueClienthttps://docs.apify.com/api/v2#/reference/request-queues/queue
| Param | Type |
| --- | --- |
| id | string |
| [options] | object |
| [options.clientKey] | object |
*
#### [](#ApifyClient+run)
apifyClient.run(id) ⇒ RunClienthttps://docs.apify.com/api/v2#/reference/actor-runs/run-object-and-its-storages
| Param | Type |
| --- | --- |
| id | string |
*
#### [](#ApifyClient+tasks)
apifyClient.tasks() ⇒ TaskCollectionClienthttps://docs.apify.com/api/v2#/reference/actor-tasks/task-collection
*
#### [](#ApifyClient+task)
apifyClient.task(id) ⇒ TaskClienthttps://docs.apify.com/api/v2#/reference/actor-tasks/task-object
| Param | Type |
| --- | --- |
| id | string |
*
#### [](#ApifyClient+schedules)
apifyClient.schedules() ⇒ ScheduleCollectionClienthttps://docs.apify.com/api/v2#/reference/schedules/schedules-collection
*
#### [](#ApifyClient+schedule)
apifyClient.schedule(id) ⇒ ScheduleClienthttps://docs.apify.com/api/v2#/reference/schedules/schedule-object
| Param | Type |
| --- | --- |
| id | string |
*
#### [](#ApifyClient+user)
apifyClient.user(id) ⇒ UserClienthttps://docs.apify.com/api/v2#/reference/users
| Param | Type |
| --- | --- |
| id | string |
*
#### [](#ApifyClient+webhooks)
apifyClient.webhooks() ⇒ WebhookCollectionClienthttps://docs.apify.com/api/v2#/reference/webhooks/webhook-collection
*
#### [](#ApifyClient+webhook)
apifyClient.webhook(id) ⇒ WebhookClienthttps://docs.apify.com/api/v2#/reference/webhooks/webhook-object
| Param | Type |
| --- | --- |
| id | string |
*
#### [](#ApifyClient+webhookDispatches)
apifyClient.webhookDispatches() ⇒ WebhookDispatchCollectionClienthttps://docs.apify.com/api/v2#/reference/webhook-dispatches
*
#### [](#ApifyClient+webhookDispatch)
apifyClient.webhookDispatch(id) ⇒ WebhookDispatchClienthttps://docs.apify.com/api/v2#/reference/webhook-dispatches/webhook-dispatch-object
| Param | Type |
| --- | --- |
| id | string |
*
$3
An
ApifyApiError is thrown for successful HTTP requests that reach the API,
but the API responds with an error response. Typically, those are rate limit
errors and internal errors, which are automatically retried, or validation
errors, which are thrown immediately, because a correction by the user is
needed.Properties
| Name | Type | Description |
| --- | --- | --- |
| message | string | Error message returned by the API. |
| clientMethod | string | The invoked resource client and the method. Known issue: Sometimes it displays as undefined because it can't be parsed from a stack trace. |
| statusCode | number | HTTP status code of the error. |
| type | string | The type of the error, as returned by the API. |
| attempt | number | Number of the API call attempt. |
| httpMethod | string | HTTP method of the API call. |
| path | string | Full path of the API endpoint (URL excluding origin). |
| originalStack | string | Original stack trace of the exception. It is replaced by a more informative stack with API call information. |
*
$3
* ActorClient
* [
.build(versionNumber, [options])](#ActorClient+build) ⇒ Promise.<Build>
* .builds() ⇒ BuildCollectionClient
* [.call([input], [options])](#ActorClient+call) ⇒ Promise.<Run>
* .delete() ⇒ Promise.<void>
* .get() ⇒ Promise.<?Actor>
* [.lastRun([options])](#ActorClient+lastRun) ⇒ RunClient
* .runs() ⇒ RunCollectionClient
* [.start([input], [options])](#ActorClient+start) ⇒ Promise.<Run>
* .update(newFields) ⇒ Promise.<Actor>
* .version(versionNumber) ⇒ ActorVersionClient
* .versions() ⇒ ActorVersionCollectionClient
* .webhooks() ⇒ WebhookCollectionClient
*
#### [](#ActorClient+build)
actorClient.build(versionNumber, [options]) ⇒ Promise.<Build>https://docs.apify.com/api/v2#/reference/actors/build-collection/build-actor
| Param | Type |
| --- | --- |
| versionNumber | string |
| [options] | object |
| [options.betaPackages] | boolean |
| [options.tag] | string |
| [options.useCache] | boolean |
| [options.waitForFinish] | number |
*
#### [](#ActorClient+builds)
actorClient.builds() ⇒ BuildCollectionClienthttps://docs.apify.com/api/v2#/reference/actors/build-collection
*
#### [](#ActorClient+call)
actorClient.call([input], [options]) ⇒ Promise.<Run>Starts an actor and waits for it to finish before returning the Run object.
It waits indefinitely, unless the
waitSecs option is provided.
https://docs.apify.com/api/v2#/reference/actors/run-collection/run-actor
| Param | Type |
| --- | --- |
| [input] | \* |
| [options] | object |
| [options.build] | string |
| [options.contentType] | string |
| [options.memory] | number |
| [options.timeout] | number |
| [options.waitSecs] | number |
| [options.webhooks] | Array.<object> |
*
#### [](#ActorClient+delete)
actorClient.delete() ⇒ Promise.<void>https://docs.apify.com/api/v2#/reference/actors/actor-object/delete-actor
*
#### [](#ActorClient+get)
actorClient.get() ⇒ Promise.<?Actor>https://docs.apify.com/api/v2#/reference/actors/actor-object/get-actor
*
#### [](#ActorClient+lastRun)
actorClient.lastRun([options]) ⇒ RunClienthttps://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages
| Param | Type |
| --- | --- |
| [options] | object |
| [options.status] | string |
*
#### [](#ActorClient+runs)
actorClient.runs() ⇒ RunCollectionClienthttps://docs.apify.com/api/v2#/reference/actors/run-collection
*
#### [](#ActorClient+start)
actorClient.start([input], [options]) ⇒ Promise.<Run>Starts an actor and immediately returns the Run object.
https://docs.apify.com/api/v2#/reference/actors/run-collection/run-actor
| Param | Type |
| --- | --- |
| [input] | \* |
| [options] | object |
| [options.build] | string |
| [options.contentType] | string |
| [options.memory] | number |
| [options.timeout] | number |
| [options.waitForFinish] | number |
| [options.webhooks] | Array.<object> |
*
#### [](#ActorClient+update)
actorClient.update(newFields) ⇒ Promise.<Actor>https://docs.apify.com/api/v2#/reference/actors/actor-object/update-actor
| Param | Type |
| --- | --- |
| newFields | object |
*
#### [](#ActorClient+version)
actorClient.version(versionNumber) ⇒ ActorVersionClienthttps://docs.apify.com/api/v2#/reference/actors/version-object
| Param | Type |
| --- | --- |
| versionNumber | string |
*
#### [](#ActorClient+versions)
actorClient.versions() ⇒ ActorVersionCollectionClienthttps://docs.apify.com/api/v2#/reference/actors/version-collection
*
#### [](#ActorClient+webhooks)
actorClient.webhooks() ⇒ WebhookCollectionClienthttps://docs.apify.com/api/v2#/reference/actors/webhook-collection
*
$3
* ActorCollectionClient
* [
.create([actor])](#ActorCollectionClient+create) ⇒ Promise.<Actor>
* [.list([options])](#ActorCollectionClient+list) ⇒ Promise.<PaginationList>
*
#### [](#ActorCollectionClient+create)
actorCollectionClient.create([actor]) ⇒ Promise.<Actor>https://docs.apify.com/api/v2#/reference/actors/actor-collection/create-actor
| Param | Type |
| --- | --- |
| [actor] | object |
*
#### [](#ActorCollectionClient+list)
actorCollectionClient.list([options]) ⇒ Promise.<PaginationList>https://docs.apify.com/api/v2#/reference/actors/actor-collection/get-list-of-actors
| Param | Type |
| --- | --- |
| [options] | object |
| [options.my] | boolean |
| [options.limit] | number |
| [options.offset] | number |
| [options.desc] | boolean |
*
$3
.delete() ⇒ Promise.<void>
* .get() ⇒ Promise.<ActorVersion>
* .update(newFields) ⇒ Promise.<ActorVersion>
*
#### [](#ActorVersionClient+delete)
actorVersionClient.delete() ⇒ Promise.<void>https://docs.apify.com/api/v2#/reference/actors/version-object/delete-version
*
#### [](#ActorVersionClient+get)
actorVersionClient.get() ⇒ Promise.<ActorVersion>https://docs.apify.com/api/v2#/reference/actors/version-object/get-version
*
#### [](#ActorVersionClient+update)
actorVersionClient.update(newFields) ⇒ Promise.<ActorVersion>https://docs.apify.com/api/v2#/reference/actors/version-object/update-version
| Param | Type |
| --- | --- |
| newFields | object |
*
$3
.create([actorVersion])](#ActorVersionCollectionClient+create) ⇒ Promise.<object>
* [.list([options])](#ActorVersionCollectionClient+list) ⇒ Promise.<PaginationList>
*
#### [](#ActorVersionCollectionClient+create)
actorVersionCollectionClient.create([actorVersion]) ⇒ Promise.<object>https://docs.apify.com/api/v2#/reference/actors/version-collection/create-version
| Param | Type |
| --- | --- |
| [actorVersion] | object |
*
#### [](#ActorVersionCollectionClient+list)
actorVersionCollectionClient.list([options]) ⇒ Promise.<PaginationList>https://docs.apify.com/api/v2#/reference/actors/version-collection/get-list-of-versions
| Param | Type |
| --- | --- |
| [options] | object |
| [options.limit] | number |
| [options.offset] | number |
| [options.desc] | boolean |
*
$3
* BuildClient
*
.abort() ⇒ Promise.<Build>
* [.get([options])](#BuildClient+get) ⇒ Promise.<Build>
* [.waitForFinish([options])](#BuildClient+waitForFinish) ⇒ Promise.<Build>
*
#### [](#BuildClient+abort)
buildClient.abort() ⇒ Promise.<Build>https://docs.apify.com/api/v2#/reference/actor-builds/abort-build/abort-build
*
#### [](#BuildClient+get)
buildClient.get([options]) ⇒ Promise.<Build>https://docs.apify.com/api/v2#/reference/actor-builds/build-object/get-build
| Param | Type |
| --- | --- |
| [options] | object |
| [options.waitForFinish] | number |
*
#### [](#BuildClient+waitForFinish)
buildClient.waitForFinish([options]) ⇒ Promise.<Build>Returns a promise that resolves with the finished Build object when the provided actor build finishes
or with the unfinished Build object when the
waitSecs timeout lapses. The promise is NOT rejected
based on run status. You can inspect the status property of the Build object to find out its status.The difference between this function and the
waitForFinish parameter of the get method
is the fact that this function can wait indefinitely. Its use is preferable to the
waitForFinish parameter alone, which it uses internally.This is useful when you need to immediately start a run after a build finishes.
| Param | Type | Description |
| --- | --- | --- |
| [options] | object | |
| [options.waitSecs] | number | Maximum time to wait for the build to finish, in seconds. If the limit is reached, the returned promise is resolved to a build object that will have status
READY or RUNNING. If waitSecs omitted, the function waits indefinitely. |
*
$3
*
#### [](#BuildCollectionClient+list)
buildCollectionClient.list([options]) ⇒ Promise.<PaginationList>https://docs.apify.com/api/v2#/reference/actors/build-collection/get-list-of-builds
| Param | Type |
| --- | --- |
| [options] | object |
| [options.limit] | number |
| [options.offset] | number |
| [options.desc] | boolean |
*
$3
* DatasetClient
*
.delete() ⇒ Promise.<void>
* [.downloadItems(format, [options])](#DatasetClient+downloadItems) ⇒ Promise.<Buffer>
* .get() ⇒ Promise.<Dataset>
* [.listItems([options])](#DatasetClient+listItems) ⇒ Promise.<PaginationList>
* .pushItems(items) ⇒ Promise.<void>
* .update(newFields) ⇒ Promise.<Dataset>
*
#### [](#DatasetClient+delete)
datasetClient.delete() ⇒ Promise.<void>https://docs.apify.com/api/v2#/reference/datasets/dataset/delete-dataset
*
#### [](#DatasetClient+downloadItems)
datasetClient.downloadItems(format, [options]) ⇒ Promise.<Buffer>Unlike
listItems which returns a PaginationList with an array of individual
dataset items, downloadItems returns the items serialized to the provided format.
https://docs.apify.com/api/v2#/reference/datasets/item-collection/get-items
| Param | Type | Description |
| --- | --- | --- |
| format | string | One of json, jsonl, xml, html, csv, xlsx, rss |
| [options] | object | |
| [options.attachment] | boolean | |
| [options.bom] | boolean | |
| [options.clean] | boolean | |
| [options.delimiter] | string | |
| [options.desc] | boolean | |
| [options.fields] | Array.<string> | |
| [options.omit] | Array.<string> | |
| [options.limit] | number | |
| [options.offset] | number | |
| [options.skipEmpty] | boolean | |
| [options.skipHeaderRow] | boolean | |
| [options.skipHidden] | boolean | |
| [options.unwind] | string | |
| [options.xmlRoot] | string | |
| [options.xmlRow] | string | |
*
#### [](#DatasetClient+get)
datasetClient.get() ⇒ Promise.<Dataset>https://docs.apify.com/api/v2#/reference/datasets/dataset/get-dataset
*
#### [](#DatasetClient+listItems)
datasetClient.listItems([options]) ⇒ Promise.<PaginationList>https://docs.apify.com/api/v2#/reference/datasets/item-collection/get-items
| Param | Type |
| --- | --- |
| [options] | object |
| [options.clean] | boolean |
| [options.desc] | boolean |
| [options.fields] | Array.<string> |
| [options.omit] | Array.<string> |
| [options.limit] | number |
| [options.offset] | number |
| [options.skipEmpty] | boolean |
| [options.skipHidden] | boolean |
| [options.unwind] | string |
*
#### [](#DatasetClient+pushItems)
datasetClient.pushItems(items) ⇒ Promise.<void>https://docs.apify.com/api/v2#/reference/datasets/item-collection/put-items
| Param | Type |
| --- | --- |
| items | object \| string \| Array.<(object\|string)> |
*
#### [](#DatasetClient+update)
datasetClient.update(newFields) ⇒ Promise.<Dataset>https://docs.apify.com/api/v2#/reference/datasets/dataset/update-dataset
| Param | Type |
| --- | --- |
| newFields | object |
*
$3
* DatasetCollectionClient
* [
.getOrCreate([name])](#DatasetCollectionClient+getOrCreate) ⇒ Promise.<object>
* [.list([options])](#DatasetCollectionClient+list) ⇒ Promise.<PaginationList>
*
#### [](#DatasetCollectionClient+getOrCreate)
datasetCollectionClient.getOrCreate([name]) ⇒ Promise.<object>https://docs.apify.com/api/v2#/reference/datasets/dataset-collection/create-dataset
| Param | Type |
| --- | --- |
| [name] | string |
*
#### [](#DatasetCollectionClient+list)
datasetCollectionClient.list([options]) ⇒ Promise.<PaginationList>https://docs.apify.com/api/v2#/reference/datasets/dataset-collection/get-list-of-datasets
| Param | Type |
| --- | --- |
| [options] | object |
| [options.unnamed] | boolean |
| [options.limit] | number |
| [options.offset] | number |
| [options.desc] | boolean |
*
$3
.delete() ⇒ Promise.<void>
* .deleteRecord(key) ⇒ Promise.<void>
* .get() ⇒ Promise.<KeyValueStore>
* [.getRecord(key, [options])](#KeyValueStoreClient+getRecord) ⇒ Promise.<(KeyValueStoreRecord\|undefined)>
* [.listKeys([options])](#KeyValueStoreClient+listKeys) ⇒ Promise.<object>
* .setRecord(record) ⇒ Promise.<void>
* .update(newFields) ⇒ Promise.<KeyValueStore>
*
#### [](#KeyValueStoreClient+delete)
keyValueStoreClient.delete() ⇒ Promise.<void>https://docs.apify.com/api/v2#/reference/key-value-stores/store-object/delete-store
*
#### [](#KeyValueStoreClient+deleteRecord)
keyValueStoreClient.deleteRecord(key) ⇒ Promise.<void>https://docs.apify.com/api/v2#/reference/key-value-stores/record/delete-record
| Param | Type |
| --- | --- |
| key | string |
*
#### [](#KeyValueStoreClient+get)
keyValueStoreClient.get() ⇒ Promise.<KeyValueStore>https://docs.apify.com/api/v2#/reference/key-value-stores/store-object/get-store
*
#### [](#KeyValueStoreClient+getRecord)
keyValueStoreClient.getRecord(key, [options]) ⇒ Promise.<(KeyValueStoreRecord\|undefined)>You can use the
buffer option to get the value in a Buffer (Node.js)
or ArrayBuffer (browser) format. In Node.js (not in browser) you can also
use the stream option to get a Readable stream.When the record does not exist, the function resolves to
undefined. It does
NOT resolve to a KeyValueStore record with an undefined value.
https://docs.apify.com/api/v2#/reference/key-value-stores/record/get-record
| Param | Type |
| --- | --- |
| key | string |
| [options] | object |
| [options.buffer] | boolean |
| [options.stream] | boolean |
*
#### [](#KeyValueStoreClient+listKeys)
keyValueStoreClient.listKeys([options]) ⇒ Promise.<object>https://docs.apify.com/api/v2#/reference/key-value-stores/key-collection/get-list-of-keys
| Param | Type |
| --- | --- |
| [options] | object |
| [options.limit] | object |
| [options.exclusiveStartKey] | string |
*
#### [](#KeyValueStoreClient+setRecord)
keyValueStoreClient.setRecord(record) ⇒ Promise.<void>https://docs.apify.com/api/v2#/reference/key-value-stores/record/put-record
| Param | Type |
| --- | --- |
| record | KeyValueStoreRecord |
*
#### [](#KeyValueStoreClient+update)
keyValueStoreClient.update(newFields) ⇒ Promise.<KeyValueStore>https://docs.apify.com/api/v2#/reference/key-value-stores/store-object/update-store
| Param | Type |
| --- | --- |
| newFields | object |
*
$3
.getOrCreate([name])](#KeyValueStoreCollectionClient+getOrCreate) ⇒ Promise.<object>
* [.list([options])](#KeyValueStoreCollectionClient+list) ⇒ Promise.<PaginationList>
*
#### [](#KeyValueStoreCollectionClient+getOrCreate)
keyValueStoreCollectionClient.getOrCreate([name]) ⇒ Promise.<object>https://docs.apify.com/api/v2#/reference/key-value-stores/store-collection/create-key-value-store
| Param | Type |
| --- | --- |
| [name] | string |
*
#### [](#KeyValueStoreCollectionClient+list)
keyValueStoreCollectionClient.list([options]) ⇒ Promise.<PaginationList>https://docs.apify.com/api/v2#/reference/key-value-stores/store-collection/get-list-of-key-value-stores
| Param | Type |
| --- | --- |
| [options] | object |
| [options.unnamed] | boolean |
| [options.limit] | number |
| [options.offset] | number |
| [options.desc] | boolean |
*
$3
Properties
| Name | Type |
| --- | --- |
| key | string |
| value | null \| string \| number \| object |
| [contentType] | string |
*
$3
* LogClient
*
.get() ⇒ Promise.<?string>
* .stream() ⇒ Promise.<?Readable>
*
#### [](#LogClient+get)
logClient.get() ⇒ Promise.<?string>https://docs.apify.com/api/v2#/reference/logs/log/get-log
*
#### [](#LogClient+stream)
logClient.stream() ⇒ Promise.<?Readable>Gets the log in a Readable stream format. Only works in Node.js.
https://docs.apify.com/api/v2#/reference/logs/log/get-log
*
$3
Properties
| Name | Type | Description |
| --- | --- | --- |
| items | Array.<object> | List of returned objects |
| total | number | Total number of objects |
| offset | number | Number of objects that were skipped |
| count | number | Number of returned objects |
| limit | number | Requested limit |
*
$3
* RequestQueueClient
* [
.addRequest(request, [options])](#RequestQueueClient+addRequest) ⇒ Promise.<object>
* .delete() ⇒ Promise.<void>
* .deleteRequest(id) ⇒ Promise.<void>
* .get() ⇒ Promise.<RequestQueue>
* .getRequest(id) ⇒ Promise.<?object>
* [.listHead([options])](#RequestQueueClient+listHead) ⇒ Promise.<object>
* .update(newFields) ⇒ Promise.<RequestQueue>
[.updateRequest(request, [options])](#RequestQueueClient+updateRequest) ⇒ Promise.<\>
*
#### [](#RequestQueueClient+addRequest)
requestQueueClient.addRequest(request, [options]) ⇒ Promise.<object>https://docs.apify.com/api/v2#/reference/request-queues/request-collection/add-request
| Param | Type |
| --- | --- |
| request | object |
| [options] | object |
| [options.forefront] | boolean |
*
#### [](#RequestQueueClient+delete)
requestQueueClient.delete() ⇒ Promise.<void>https://docs.apify.com/api/v2#/reference/request-queues/queue/delete-request-queue
*
#### [](#RequestQueueClient+deleteRequest)
requestQueueClient.deleteRequest(id) ⇒ Promise.<void>
| Param | Type |
| --- | --- |
| id | string |
*
#### [](#RequestQueueClient+get)
requestQueueClient.get() ⇒ Promise.<RequestQueue>https://docs.apify.com/api/v2#/reference/request-queues/queue/get-request-queue
*
#### [](#RequestQueueClient+getRequest)
requestQueueClient.getRequest(id) ⇒ Promise.<?object>https://docs.apify.com/api/v2#/reference/request-queues/request/get-request
| Param | Type |
| --- | --- |
| id | string |
*
#### [](#RequestQueueClient+listHead)
requestQueueClient.listHead([options]) ⇒ Promise.<object>https://docs.apify.com/api/v2#/reference/request-queues/queue-head/get-head
| Param | Type |
| --- | --- |
| [options] | object |
| [options.limit] | number |
*
#### [](#RequestQueueClient+update)
requestQueueClient.update(newFields) ⇒ Promise.<RequestQueue>https://docs.apify.com/api/v2#/reference/request-queues/queue/update-request-queue
| Param | Type |
| --- | --- |
| newFields | object |
*
#### [](#RequestQueueClient+updateRequest)
requestQueueClient.updateRequest(request, [options]) ⇒ Promise.<\*>https://docs.apify.com/api/v2#/reference/request-queues/request/update-request
| Param | Type |
| --- | --- |
| request | object |
| [options] | object |
| [options.forefront] | boolean |
*
$3
* RequestQueueCollection
* [
.getOrCreate([name])](#RequestQueueCollection+getOrCreate) ⇒ Promise.<RequestQueue>
* [.list([options])](#RequestQueueCollection+list) ⇒ Promise.<PaginationList>
*
#### [](#RequestQueueCollection+getOrCreate)
requestQueueCollection.getOrCreate([name]) ⇒ Promise.<RequestQueue>https://docs.apify.com/api/v2#/reference/request-queues/queue-collection/create-request-queue
| Param | Type |
| --- | --- |
| [name] | string |
*
#### [](#RequestQueueCollection+list)
requestQueueCollection.list([options]) ⇒ Promise.<PaginationList>https://docs.apify.com/api/v2#/reference/request-queues/queue-collection/get-list-of-request-queues
| Param | Type |
| --- | --- |
| [options] | object |
| [options.unnamed] | boolean |
| [options.limit] | number |
| [options.offset] | number |
| [options.desc] | boolean |
*
$3
* RunClient
*
.abort() ⇒ Promise.<Run>
* .dataset() ⇒ DatasetClient
* [.get([options])](#RunClient+get) ⇒ Promise.<Run>
* .keyValueStore() ⇒ KeyValueStoreClient
* .log() ⇒ LogClient
* [.metamorph(targetActorId, [input], [options])](#RunClient+metamorph) ⇒ Promise.<Run>
* .requestQueue() ⇒ RequestQueueClient
* [.resurrect([options])](#RunClient+resurrect) ⇒ Promise.<Run>
* [.waitForFinish([options])](#RunClient+waitForFinish) ⇒ Promise.<Run>
*
#### [](#RunClient+abort)
runClient.abort() ⇒ Promise.<Run>https://docs.apify.com/api/v2#/reference/actor-runs/abort-run/abort-run
*
#### [](#RunClient+dataset)
runClient.dataset() ⇒ DatasetClienthttps://docs.apify.com/api/v2#/reference/actor-runs/run-object-and-its-storages
This also works through
actorClient.lastRun().dataset().
https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages
*
#### [](#RunClient+get)
runClient.get([options]) ⇒ Promise.<Run>https://docs.apify.com/api/v2#/reference/actor-runs/run-object/get-run
| Param | Type |
| --- | --- |
| [options] | object |
| [options.waitForFinish] | number |
*
#### [](#RunClient+keyValueStore)
runClient.keyValueStore() ⇒ KeyValueStoreClienthttps://docs.apify.com/api/v2#/reference/actor-runs/run-object-and-its-storages
This also works through
actorClient.lastRun().keyValueStore().
https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages
*
#### [](#RunClient+log)
runClient.log() ⇒ LogClienthttps://docs.apify.com/api/v2#/reference/actor-runs/run-object-and-its-storages
This also works through
actorClient.lastRun().log().
https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages
*
#### [](#RunClient+metamorph)
runClient.metamorph(targetActorId, [input], [options]) ⇒ Promise.<Run>https://docs.apify.com/api/v2#/reference/actor-runs/metamorph-run/metamorph-run
| Param | Type |
| --- | --- |
| targetActorId | string |
| [input] | \* |
| [options] | object |
| [options.contentType] | object |
| [options.build] | object |
*
#### [](#RunClient+requestQueue)
runClient.requestQueue() ⇒ RequestQueueClienthttps://docs.apify.com/api/v2#/reference/actor-runs/run-object-and-its-storages
This also works through
actorClient.lastRun().requestQueue().
https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages
*
#### [](#RunClient+resurrect)
runClient.resurrect([options]) ⇒ Promise.<Run>https://docs.apify.com/api/v2#/reference/actor-runs/resurrect-run/resurrect-run
| Param | Type |
| --- | --- |
| [options] | object |
| [options.build] | string |
| [options.memory] | number |
| [options.timeout] | number |
*
#### [](#RunClient+waitForFinish)
runClient.waitForFinish([options]) ⇒ Promise.<Run>Returns a promise that resolves with the finished Run object when the provided actor run finishes
or with the unfinished Run object when the
waitSecs timeout lapses. The promise is NOT rejected
based on run status. You can inspect the status property of the Run object to find out its status.The difference between this function and the
waitForFinish parameter of the get method
is the fact that this function can wait indefinitely. Its use is preferable to the
waitForFinish parameter alone, which it uses internally.This is useful when you need to chain actor executions. Similar effect can be achieved
by using webhooks, so be sure to review which technique fits your use-case better.
| Param | Type | Description |
| --- | --- | --- |
| [options] | object | |
| [options.waitSecs] | number | Maximum time to wait for the run to finish, in seconds. If the limit is reached, the returned promise is resolved to a run object that will have status
READY or RUNNING. If waitSecs omitted, the function waits indefinitely. |
*
$3
*
#### [](#RunCollectionClient+list)
runCollectionClient.list([options]) ⇒ Promise.<PaginationList>https://docs.apify.com/api/v2#/reference/actors/run-collection/get-list-of-runs
| Param | Type |
| --- | --- |
| [options] | object |
| [options.limit] | number |
| [options.offset] | number |
| [options.desc] | boolean |
| [options.status] | boolean |
*
$3
* ScheduleClient
*
.delete() ⇒ Promise.<void>
* .get() ⇒ Promise.<?Schedule>
* .getLog() ⇒ Promise.<?string>
* .update(newFields) ⇒ Promise.<Schedule>
*
#### [](#ScheduleClient+delete)
scheduleClient.delete() ⇒ Promise.<void>https://docs.apify.com/api/v2#/reference/schedules/schedule-object/delete-schedule
*
#### [](#ScheduleClient+get)
scheduleClient.get() ⇒ Promise.<?Schedule>https://docs.apify.com/api/v2#/reference/schedules/schedule-object/get-schedule
*
#### [](#ScheduleClient+getLog)
scheduleClient.getLog() ⇒ Promise.<?string>https://docs.apify.com/api/v2#/reference/schedules/schedule-log/get-schedule-log
*
#### [](#ScheduleClient+update)
scheduleClient.update(newFields) ⇒ Promise.<Schedule>https://docs.apify.com/api/v2#/reference/schedules/schedule-object/update-schedule
| Param | Type |
| --- | --- |
| newFields | object |
*
$3
* ScheduleCollectionClient
* [
.create([schedule])](#ScheduleCollectionClient+create) ⇒ Promise.<Schedule>
* [.list([options])](#ScheduleCollectionClient+list) ⇒ Promise.<PaginationList>
*
#### [](#ScheduleCollectionClient+create)
scheduleCollectionClient.create([schedule]) ⇒ Promise.<Schedule>https://docs.apify.com/api/v2#/reference/schedules/schedules-collection/create-schedule
| Param | Type |
| --- | --- |
| [schedule] | object |
*
#### [](#ScheduleCollectionClient+list)
scheduleCollectionClient.list([options]) ⇒ Promise.<PaginationList>https://docs.apify.com/api/v2#/reference/schedules/schedules-collection/get-list-of-schedules
| Param | Type |
| --- | --- |
| [options] | object |
| [options.limit] | number |
| [options.offset] | number |
| [options.desc] | boolean |
*
$3
* TaskClient
* [
.call([input], [options])](#TaskClient+call) ⇒ Promise.<Run>
* .delete() ⇒ Promise.<void>
* .get() ⇒ Promise.<?Task>
* .getInput() ⇒ Promise.<?object>
* .lastRun(options) ⇒ RunClient
* .runs() ⇒ RunCollectionClient
* [.start([input], [options])](#TaskClient+start) ⇒ Promise.<Run>
* .update(newFields) ⇒ Promise.<Task>
* .updateInput() ⇒ Promise.<object>
* .webhooks() ⇒ WebhookCollectionClient
*
#### [](#TaskClient+call)
taskClient.call([input], [options]) ⇒ Promise.<Run>Starts a task and waits for it to finish before returning the Run object.
It waits indefinitely, unless the
waitSecs option is provided.
https://docs.apify.com/api/v2#/reference/actor-tasks/run-collection/run-task
| Param | Type |
| --- | --- |
| [input] | object |
| [options] | object |
| [options.build] | string |
| [options.memory] | number |
| [options.timeout] | number |
| [options.waitSecs] | number |
| [options.webhooks] | Array.<object> |
*
#### [](#TaskClient+delete)
taskClient.delete() ⇒ Promise.<void>https://docs.apify.com/api/v2#/reference/actor-tasks/task-object/delete-task
*
#### [](#TaskClient+get)
taskClient.get() ⇒ Promise.<?Task>https://docs.apify.com/api/v2#/reference/actor-tasks/task-object/get-task
*
#### [](#TaskClient+getInput)
taskClient.getInput() ⇒ Promise.<?object>https://docs.apify.com/api/v2#/reference/actor-tasks/task-input-object/get-task-input
*
#### [](#TaskClient+lastRun)
taskClient.lastRun(options) ⇒ RunClienthttps://docs.apify.com/api/v2#/reference/actor-tasks/last-run-object-and-its-storages
| Param | Type |
| --- | --- |
| options | object |
| options.status | string |
*
#### [](#TaskClient+runs)
taskClient.runs() ⇒ RunCollectionClienthttps://docs.apify.com/api/v2#/reference/actor-tasks/run-collection
*
#### [](#TaskClient+start)
taskClient.start([input], [options]) ⇒ Promise.<Run>Starts a task and immediately returns the Run object.
https://docs.apify.com/api/v2#/reference/actor-tasks/run-collection/run-task
| Param | Type |
| --- | --- |
| [input] | object |
| [options] | object |
| [options.build] | string |
| [options.memory] | number |
| [options.timeout] | number |
| [options.waitForFinish] | number |
| [options.webhooks] | Array.<object> |
*
#### [](#TaskClient+update)
taskClient.update(newFields) ⇒ Promise.<Task>https://docs.apify.com/api/v2#/reference/actor-tasks/task-object/update-task
| Param | Type |
| --- | --- |
| newFields | object |
*
#### [](#TaskClient+updateInput)
taskClient.updateInput() ⇒ Promise.<object>https://docs.apify.com/api/v2#/reference/actor-tasks/task-input-object/update-task-input
*
#### [](#TaskClient+webhooks)
taskClient.webhooks() ⇒ WebhookCollectionClienthttps://docs.apify.com/api/v2#/reference/actor-tasks/webhook-collection
*
$3
* TaskCollectionClient
* [
.create([task])](#TaskCollectionClient+create) ⇒ Promise.<Task>
* [.list([options])](#TaskCollectionClient+list) ⇒ Promise.<PaginationList>
*
#### [](#TaskCollectionClient+create)
taskCollectionClient.create([task]) ⇒ Promise.<Task>https://docs.apify.com/api/v2#/reference/actor-tasks/task-collection/create-task
| Param | Type |
| --- | --- |
| [task] | object |
*
#### [](#TaskCollectionClient+list)
taskCollectionClient.list([options]) ⇒ Promise.<PaginationList>https://docs.apify.com/api/v2#/reference/actor-tasks/task-collection/get-list-of-tasks
| Param | Type |
| --- | --- |
| [options] | object |
| [options.limit] | number |
| [options.offset] | number |
| [options.desc] | boolean |
*
$3
*
#### [](#UserClient+get)
userClient.get() ⇒ Promise.<?User>Depending on whether ApifyClient was created with a token,
the method will either return public or private user data.
https://docs.apify.com/api/v2#/reference/users
*
$3
* WebhookClient
*
.delete() ⇒ Promise.<void>
* .dispatches() ⇒ WebhookDispatchCollectionClient
* .get() ⇒ Promise.<?Webhook>
* .update(newFields) ⇒ Promise.<Webhook>
*
#### [](#WebhookClient+delete)
webhookClient.delete() ⇒ Promise.<void>https://docs.apify.com/api/v2#/reference/webhooks/webhook-object/delete-webhook
*
#### [](#WebhookClient+dispatches)
webhookClient.dispatches() ⇒ WebhookDispatchCollectionClienthttps://docs.apify.com/api/v2#/reference/webhooks/dispatches-collection
*
#### [](#WebhookClient+get)
webhookClient.get() ⇒ Promise.<?Webhook>https://docs.apify.com/api/v2#/reference/webhooks/webhook-object/get-webhook
*
#### [](#WebhookClient+update)
webhookClient.update(newFields) ⇒ Promise.<Webhook>https://docs.apify.com/api/v2#/reference/webhooks/webhook-object/update-webhook
| Param | Type |
| --- | --- |
| newFields | object |
*
$3
* WebhookCollectionClient
* [
.create([webhook])](#WebhookCollectionClient+create) ⇒ Promise.<Webhook>
* [.list([options])](#WebhookCollectionClient+list) ⇒ Promise.<PaginationList>
*
#### [](#WebhookCollectionClient+create)
webhookCollectionClient.create([webhook]) ⇒ Promise.<Webhook>https://docs.apify.com/api/v2#/reference/webhooks/webhook-collection/create-webhook
| Param | Type |
| --- | --- |
| [webhook] | object |
*
#### [](#WebhookCollectionClient+list)
webhookCollectionClient.list([options]) ⇒ Promise.<PaginationList>https://docs.apify.com/api/v2#/reference/webhooks/webhook-collection/get-list-of-webhooks
| Param | Type |
| --- | --- |
| [options] | object |
| [options.limit] | number |
| [options.offset] | number |
| [options.desc] | boolean |
*
$3
*
#### [](#WebhookDispatchClient+get)
webhookDispatchClient.get() ⇒ Promise.<?WebhookDispatch>https://docs.apify.com/api/v2#/reference/webhook-dispatches/webhook-dispatch-object/get-webhook-dispatch
*
$3
*
#### [](#WebhookDispatchCollectionClient+list)
webhookDispatchCollectionClient.list([options])` ⇒ Promise.<PaginationList>https://docs.apify.com/api/v2#/reference/webhook-dispatches/webhook-dispatches-collection/get-list-of-webhook-dispatches
| Param | Type |
| --- | --- |
| [options] | object |
| [options.limit] | number |
| [options.offset] | number |
| [options.desc] | boolean |
*