Skip to main content

ApifyKeyValueStoreClient

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

Index

Methods

__init__

  • __init__(*, api_client, api_public_base_url, lock): None
  • Initialize a new instance.

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


    Parameters

    • keyword-onlyapi_client: KeyValueStoreClientAsync
    • keyword-onlyapi_public_base_url: str
    • keyword-onlylock: asyncio.Lock

    Returns None

delete_value

  • async delete_value(key): None
  • Parameters

    • key: str

    Returns None

drop

  • async drop(): None
  • Returns None

get_metadata

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

    • key: str

      The key for which the URL should be generated.

    Returns str

get_value

  • async get_value(key): KeyValueStoreRecord | None
  • Parameters

    • key: str

    Returns KeyValueStoreRecord | None

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

  • 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 an existing key-value store to open. If provided, the client will connect to this specific storage. Cannot be used together with name.

    • keyword-onlyname: str | None

      The name of a key-value store to get or create. If a storage with this name exists, it will be opened; otherwise, a new one will be created. Cannot be used together with id.

    • keyword-onlyconfiguration: Configuration

      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 nor name is provided.

    Returns ApifyKeyValueStoreClient

purge

  • async purge(): None
  • Returns None

record_exists

  • async record_exists(key): bool
  • Parameters

    • key: str

    Returns bool

set_value

  • async set_value(key, value, content_type): None
  • Parameters

    • key: str
    • value: Any
    • optionalcontent_type: str | None = None

    Returns None