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.
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.
- JavaScript
- Python
import { Actor } from 'apify';
await Actor.init();
const otherDataset = await Actor.openDataset('old-dataset');
// ...
await Actor.exit();
from apify import Actor
async def main():
async with Actor:
other_dataset = await Actor.open_dataset(name='old-dataset')
# ...
Only the method name changes with the storage type:
| Storage type | JavaScript SDK | Python SDK |
|---|---|---|
| Dataset | Actor.openDataset() | Actor.open_dataset() |
| Key-value store | Actor.openKeyValueStore() | Actor.open_key_value_store() |
| Request queue | Actor.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.
- JavaScript
- Python
const otherDatasetClient = apifyClient.dataset('jane-doe/old-dataset');
other_dataset_client = apify_client.dataset('jane-doe/old-dataset')
Only the accessor changes with the storage type:
| Storage type | JavaScript client | Python client |
|---|---|---|
| Dataset | apifyClient.dataset() | apify_client.dataset() |
| Key-value store | apifyClient.keyValueStore() | apify_client.key_value_store() |
| Request queue | apifyClient.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.