Skip to main content
Version: Next

ApifyStorageBackend

Bridges apify-client's synchronous resource accessors (dataset(id), keyValueStore(id), requestQueue(id, options?)) to crawlee v4's StorageBackend interface (async factory methods accepting an id, a name, or an alias).

Actor wires this up automatically; construct it directly only to use Apify platform storage with crawlee's storage classes outside of Actor — e.g. to read another run's output with an explicit token:

import { ApifyClient, ApifyStorageBackend, Dataset } from 'apify';

const client = new ApifyClient({ token });
const dataset = await Dataset.open(datasetId, { storageBackend: new ApifyStorageBackend(client) });
const { items } = await dataset.getData();

Implements

  • StorageBackend

Index

Constructors

constructor

Methods

createDatasetBackend

  • createDatasetBackend(options): Promise<DatasetBackend<Dictionary>>
  • Create (or open) a dataset backend. If id is provided, opens the dataset with that ID. If name is provided, opens an existing dataset with that name or creates a new one. If neither is provided, opens or creates the default dataset.


    Parameters

    • optionaloptions: StorageIdentifier

    Returns Promise<DatasetBackend<Dictionary>>

createKeyValueStoreBackend

  • createKeyValueStoreBackend(options): Promise<KeyValueStoreBackend>
  • Create (or open) a key-value store backend. If id is provided, opens the key-value store with that ID. If name is provided, opens an existing store with that name or creates a new one. If neither is provided, opens or creates the default key-value store.


    Parameters

    • optionaloptions: StorageIdentifier

    Returns Promise<KeyValueStoreBackend>

createRequestQueueBackend

  • createRequestQueueBackend(options): Promise<RequestQueueBackend>
  • Create (or open) a request queue backend. If id is provided, opens the request queue with that ID. If name is provided, opens an existing queue with that name or creates a new one. If neither is provided, opens or creates the default request queue.


    Parameters

    • optionaloptions: StorageIdentifier

    Returns Promise<RequestQueueBackend>

getStorageBackendCacheKey

  • getStorageBackendCacheKey(): string
  • Partitions crawlee's storage-instance cache by API base URL and token, so the same storage opened through two differently-authenticated backends is cached separately. The request queue access mode is deliberately not part of the key — opening the same queue in single and shared mode at once is not supported, and whichever backend opens it first wins.


    Returns string

storageExists

  • storageExists(id, type): Promise<boolean>
  • Check whether a storage with the given ID exists.

    Used internally to resolve ambiguous idOrName strings passed to Dataset.open(), KeyValueStore.open(), and RequestQueue.open().


    Parameters

    • id: string
    • type: StorageType

    Returns Promise<boolean>