Skip to main content

Use storage from another run

If you have the storage's name or ID, you can access it from any Actor or task run. Use the same methods and endpoints you'd use for the current run's storages: open the storage with the SDK, open it with an API client, or call the Apify API.

Datasets and key-value stores support concurrent use. Multiple Actors or tasks can write to the same dataset or key-value store, and multiple runs can read from them at the same time.

Request queues only allow multiple runs to add new data. A request queue can be processed by one Actor or task run at a time. However, you can use request locking to coordinate multiple runs.

When multiple runs use the same storage at the same time, the order in which their operations are processed is not guaranteed. For example, if a delete of a key-value store record is processed before a read of the same record, the read fails.

Accessing restricted storage resources between runs

If a storage resource access is set to Restricted, the run from which it's accessed must have explicit access to it. Learn how restricted access works and how to grant it.

Open a storage with the SDK

Open the storage with the same method you would use for the current run's storage, and pass the name or ID of the one you want.

import { Actor } from 'apify';

await Actor.init();

const otherDataset = await Actor.openDataset('old-dataset');
// ...

await Actor.exit();

Only the method name changes with the storage type:

Storage typeJavaScript SDKPython SDK
DatasetActor.openDataset()Actor.open_dataset()
Key-value storeActor.openKeyValueStore()Actor.open_key_value_store()
Request queueActor.openRequestQueue()Actor.open_request_queue()

Open a storage with an API client

Construct the storage's client with the name or ID of the storage you want. To use a storage owned by another user, prefix the name with their username, as in jane-doe/old-dataset. Then read and write exactly as you would with the current run's storage.

const otherDatasetClient = apifyClient.dataset('jane-doe/old-dataset');

Only the accessor changes with the storage type:

Storage typeJavaScript clientPython client
DatasetapifyClient.dataset()apify_client.dataset()
Key-value storeapifyClient.keyValueStore()apify_client.key_value_store()
Request queueapifyClient.requestQueue()apify_client.request_queue()

Use the Apify API

Send requests to the same endpoints you would use for the current run's storages, passing the name or ID of the storage you want. See the endpoint reference for datasets, key-value stores, and request queues.