Key-value store

Store anything from actor or task run results JSON documents or images. Learn how to access and manage key-value stores from the Apify app or via API.

The key-value store is simple storage that can be used for storing any kind of data. It can be JSON or HTML documents, zip files, images, or simply strings. The data are stored along with their MIME content type.

Each actor run is assigned its own key-value store when it is created. The store contains the actor's input, and, if necessary, other stores such as its output.

Key-value stores are mutable–you can both add entries and delete them.

Named key-value stores are retained indefinitely.
Unnamed key-value stores expire after 7 days unless otherwise specified.
Learn about named and unnamed key-value stores.

Basic usage

There are four ways to access your key-value stores:

Apify app

In the Apify app, you can view your key-value stores in the Storage section under the Key-value stores tab.

Only named key-value stores are displayed by default. Select the Include unnamed key-value stores checkbox to display all of your stores.

Key-value stores in app

To view a key-value store's content, click on its Store ID, then click on a store's View button. In the detail page, under the Settings tab, you can update the store's name (and, in turn, its retention period) and access rights. The API tab allows you to view and test a store's API endpoints.

Key-value stores detail

Apify SDK

If you are building an Apify actor, you will be using the Apify software development kit (SDK). In the Apify SDK, the key-value store is represented by the KeyValueStore class.

You can use the KeyValueStore class to specify whether your data is stored locally or in the Apify cloud, get and set values using the Apify.getValue() and Apify.setValue() methods or iterate over your key-value store keys using the forEachKey() method.

Each actor run is associated with the default key-value store, which is created for the actor run. When running your actors and storing data locally, you can pass its input using the INPUT.json key-value store.

You can find INPUT.json and other key-value stores in the location below.


The default key-value store's ID is default. The {KEY} is the record's key and {EXT} corresponds to the data value's MIME content type.

To manage your key-value stores, you can use the following methods. See the KeyValueStore class's API reference for the full list.

// Get the default input
const input = await Apify.getInput();

// Open a named key-value store
const exampleStore = await Apify.openKeyValueStore('my-store');

// Read a record in the exampleStore storage
const value = await exampleStore.getValue('some-key');

// Write a record to exampleStore
await exampleStore.setValue('some-key', { foo: 'bar' });

// Delete a record in exampleStore
await exampleStore.setValue('some-key', null);

Note that JSON is automatically parsed to a JavaScript object, text data returned as a string and other data is returned as binary buffer.

const Apify = require('apify');

// The optional Apify.main() function performs the
// actor's job and terminates the process when it is finished
Apify.main(async () => {
    // Get input of your actor
    const input = await Apify.getInput();
    const value = await Apify.getValue('my-key');

    // ...

    await Apify.setValue(
        { contentType: 'image/jpeg' },

The Apify.getInput()method is not only a shortcut to Apify.getValue('INPUT')- it is also compatible with Apify.metamorph() [docs]. This is because a metamorphed actor run's input is stored in the INPUT-METAMORPH-1 key instead of INPUT, which hosts the original input.

See the SDK documentation and the KeyValueStore class's API reference for details on managing your key-value stores with the Apify SDK.

JavaScript API client

Apify's JavaScript API client (apify-client) allows you to access your key-value stores from any Node.js application, whether it is running on the Apify platform or elsewhere.

After importing and initiating the client, you can save each key-value store to a variable for easier access.

const myKeyValStoreClient = apifyClient.keyValueStore('jane-doe/my-key-val-store');

You can then use that variable to access the key-value store's items and manage it.

See the JavaScript API client documentation for help with setup and more details.

Apify API

The Apify API allows you to access your key-value stores programmatically using HTTP requests and easily share your crawling results.

If you are accessing your datasets using the username~store-name store ID format, you will need to use your secret API token. You can find the token (and your user ID) on the Integrations page of your Apify account.

When providing your API authentication token, we recommend using the request's Authorization header, rather than the URL. (More info).

To get a list of your key-value stores, send a GET request to the Get list of key-value stores endpoint.


To get information about a key-value store such as its creation time and item count, send a GET request to the Get store endpoint.


To get a record (its value) from a key-value store, send a GET request to the Get record endpoint.


To add a record to a specific key in a key-value store, send a PUT request to the Put record endpoint.


Example payload:

    "foo": "bar",
    "fos": "baz"

To delete a record, send a DELETE request specifying the key from a key-value store to the Delete record endpoint.


See the API documentation for a detailed breakdown of each API endpoint.


In the past, every record uploaded using the Put record endpoint was compressed using Gzip before uploading. This has changed. Now, records are stored in the state you upload them. This means it is up to you if the record is stored compressed or uncompressed.

You can compress a record and use the Content-Encoding request header to let our platform know which compression it uses. We recommend compressing large key-value records to save storage space and network traffic.

If you use the Apify SDK or our JavaScript API client, your files are compressed automatically by default. We recommend using the JavaScript API client, which compresses your data before they are sent to our servers and decompresses them when you retrieve them. This makes your storage costs as low as possible.


You can invite other Apify users to view or modify your key-value stores using the access rights system. See the full list of permissions.

Sharing key-value stores between runs

You can access a key-value store from any actor or task run as long as you know its name or ID.

To access a key-value store from another run using the Apify SDK, open it using the Apify.openDataset([store]) method like you would any other store.

const otherStore = await Apify.openKeyValueStore('old-store');

In the JavaScript API client, you can access a store using its client. Once you've opened a store, read and manage its contents like you would with a key-value store from your current run.

const otherStoreClient = apifyClient.keyValueStore('jane-doe/old-store');

The same applies for the Apify API - you can use the same endpoints as you would normally.

See the Storage overview for details on sharing storages between runs.

Data consistency

Key-value storage uses the AWS S3 service. According to the S3 documentation, it provides strong read-after-write consistency.


  • Key-value store names can be up to 63 characters long.