# ApifyKeyValueStoreClient<!-- -->

An Apify platform implementation of the key-value store client.

## Index[](#Index)

### Methods

* [\_\_init\_\_](https://docs.apify.com/sdk/python/reference/class/ApifyKeyValueStoreClient.md#__init__)
* [delete_value](https://docs.apify.com/sdk/python/reference/class/ApifyKeyValueStoreClient.md#delete_value)
* [drop](https://docs.apify.com/sdk/python/reference/class/ApifyKeyValueStoreClient.md#drop)
* [get_metadata](https://docs.apify.com/sdk/python/reference/class/ApifyKeyValueStoreClient.md#get_metadata)
* [get_public_url](https://docs.apify.com/sdk/python/reference/class/ApifyKeyValueStoreClient.md#get_public_url)
* [get_value](https://docs.apify.com/sdk/python/reference/class/ApifyKeyValueStoreClient.md#get_value)
* [iterate_keys](https://docs.apify.com/sdk/python/reference/class/ApifyKeyValueStoreClient.md#iterate_keys)
* [open](https://docs.apify.com/sdk/python/reference/class/ApifyKeyValueStoreClient.md#open)
* [purge](https://docs.apify.com/sdk/python/reference/class/ApifyKeyValueStoreClient.md#purge)
* [record_exists](https://docs.apify.com/sdk/python/reference/class/ApifyKeyValueStoreClient.md#record_exists)
* [set_value](https://docs.apify.com/sdk/python/reference/class/ApifyKeyValueStoreClient.md#set_value)

## Methods<!-- -->[](#Methods)

### [](#__init__)[](https://github.com/apify/apify-sdk-python/blob/c674a4d42ade9c1a07f33062b6702497cd34b19d//src/apify/storage_clients/_apify/_key_value_store_client.py#L28)\_\_init\_\_

* **\_\_init\_\_**(\*, api_client, lock): None

- Initialize a new instance.

  Preferably use the `ApifyKeyValueStoreClient.open` class method to create a new instance.

  ***

  #### Parameters

  * ##### keyword-onlyapi_client: KeyValueStoreClientAsync
  * ##### keyword-onlylock: asyncio.Lock

  #### Returns None

### [](#delete_value)[](https://github.com/apify/apify-sdk-python/blob/c674a4d42ade9c1a07f33062b6702497cd34b19d//src/apify/storage_clients/_apify/_key_value_store_client.py#L132)delete_value

* async **delete_value**(\*, key): None

- #### Parameters

  * ##### keyword-onlykey: str

  #### Returns None

### [](#drop)[](https://github.com/apify/apify-sdk-python/blob/c674a4d42ade9c1a07f33062b6702497cd34b19d//src/apify/storage_clients/_apify/_key_value_store_client.py#L113)drop

* async **drop**(): None

- #### Returns None

### [](#get_metadata)[](https://github.com/apify/apify-sdk-python/blob/c674a4d42ade9c1a07f33062b6702497cd34b19d//src/apify/storage_clients/_apify/_key_value_store_client.py#L45)get_metadata

* async **get_metadata**(): [ApifyKeyValueStoreMetadata](https://docs.apify.com/sdk/python/reference/class/ApifyKeyValueStoreMetadata.md)

- #### Returns [ApifyKeyValueStoreMetadata](https://docs.apify.com/sdk/python/reference/class/ApifyKeyValueStoreMetadata.md)

### [](#get_public_url)[](https://github.com/apify/apify-sdk-python/blob/c674a4d42ade9c1a07f33062b6702497cd34b19d//src/apify/storage_clients/_apify/_key_value_store_client.py#L172)get_public_url

* async **get_public_url**(\*, key): str

- Get a URL for the given key that may be used to publicly access the value in the remote key-value store.

  ***

  #### Parameters

  * ##### keyword-onlykey: str

    The key for which the URL should be generated.

  #### Returns str

  A public URL that can be used to access the value of the given key in the KVS.

### [](#get_value)[](https://github.com/apify/apify-sdk-python/blob/c674a4d42ade9c1a07f33062b6702497cd34b19d//src/apify/storage_clients/_apify/_key_value_store_client.py#L118)get_value

* async **get_value**(\*, key): KeyValueStoreRecord | None

- #### Parameters

  * ##### keyword-onlykey: str

  #### Returns KeyValueStoreRecord | None

### [](#iterate_keys)[](https://github.com/apify/apify-sdk-python/blob/c674a4d42ade9c1a07f33062b6702497cd34b19d//src/apify/storage_clients/_apify/_key_value_store_client.py#L137)iterate_keys

* async **iterate_keys**(\*, exclusive_start_key, limit): AsyncIterator\[KeyValueStoreRecordMetadata]

- #### Parameters

  * ##### optionalkeyword-onlyexclusive_start_key: str | None = <!-- -->None
  * ##### optionalkeyword-onlylimit: int | None = <!-- -->None

  #### Returns AsyncIterator\[KeyValueStoreRecordMetadata]

### [](#open)[](https://github.com/apify/apify-sdk-python/blob/c674a4d42ade9c1a07f33062b6702497cd34b19d//src/apify/storage_clients/_apify/_key_value_store_client.py#L61)open

* async **open**(\*, id, name, alias, configuration): [ApifyKeyValueStoreClient](https://docs.apify.com/sdk/python/reference/class/ApifyKeyValueStoreClient.md)

- Open an Apify key-value store client.

  This method creates and initializes a new instance of the Apify key-value store client. It handles authentication, storage lookup/creation, and metadata retrieval.

  ***

  #### Parameters

  * ##### keyword-onlyid: str | None

    The ID of the KVS to open. If provided, searches for existing KVS by ID. Mutually exclusive with name and alias.

  * ##### keyword-onlyname: str | None

    The name of the KVS to open (global scope, persists across runs). Mutually exclusive with id and alias.

  * ##### keyword-onlyalias: str | None

    The alias of the KVS to open (run scope, creates unnamed storage). Mutually exclusive with id and name.

  * ##### keyword-onlyconfiguration: [Configuration](https://docs.apify.com/sdk/python/reference/class/Configuration.md)

    The configuration object containing API credentials and settings. Must include a valid `token` and `api_base_url`. May also contain a `default_key_value_store_id` for fallback when neither `id`, `name`, nor `alias` is provided.

  #### Returns [ApifyKeyValueStoreClient](https://docs.apify.com/sdk/python/reference/class/ApifyKeyValueStoreClient.md)

  An instance for the opened or created storage client.

### [](#purge)[](https://github.com/apify/apify-sdk-python/blob/c674a4d42ade9c1a07f33062b6702497cd34b19d//src/apify/storage_clients/_apify/_key_value_store_client.py#L106)purge

* async **purge**(): None

- #### Returns None

### [](#record_exists)[](https://github.com/apify/apify-sdk-python/blob/c674a4d42ade9c1a07f33062b6702497cd34b19d//src/apify/storage_clients/_apify/_key_value_store_client.py#L168)record_exists

* async **record_exists**(\*, key): bool

- #### Parameters

  * ##### keyword-onlykey: str

  #### Returns bool

### [](#set_value)[](https://github.com/apify/apify-sdk-python/blob/c674a4d42ade9c1a07f33062b6702497cd34b19d//src/apify/storage_clients/_apify/_key_value_store_client.py#L123)set_value

* async **set_value**(\*, key, value, content_type): None

- #### Parameters

  * ##### keyword-onlykey: str
  * ##### keyword-onlyvalue: Any
  * ##### optionalkeyword-onlycontent_type: str | None = <!-- -->None

  #### Returns None
