Skip to main content

KeyValueStoreClientAsync

Sub-client for managing a specific key-value store.

Provides methods to manage a specific key-value store, e.g. get it, update it, or manage its records. Obtain an instance via an appropriate method on the ApifyClientAsync class.

Hierarchy

Index

Methods

__init__

  • __init__(*, base_url, public_base_url, http_client, resource_path, client_registry, resource_id, params): None
  • Initialize the resource client.


    Parameters

    • keyword-onlybase_url: str

      API base URL.

    • keyword-onlypublic_base_url: str

      Public CDN base URL.

    • keyword-onlyhttp_client: HttpClientAsync

      HTTP client for making requests.

    • keyword-onlyresource_path: str

      Resource endpoint path (e.g., 'actors', 'datasets').

    • keyword-onlyclient_registry: ClientRegistryAsync

      Bundle of client classes for dependency injection.

    • optionalkeyword-onlyresource_id: str | None = None

      Optional resource ID for single-resource clients.

    • optionalkeyword-onlyparams: dict | None = None

      Optional default parameters for all requests.

    Returns None

create_keys_public_url

  • async create_keys_public_url(*, limit, exclusive_start_key, collection, prefix, expires_in): str
  • Generate a URL that can be used to access key-value store keys.

    If the client has permission to access the key-value store's URL signing key, the URL will include a signature to verify its authenticity.

    You can optionally control how long the signed URL should be valid using the expires_in option. This value sets the expiration duration from the time the URL is generated. If not provided, the URL will not expire.

    Any other options (like limit or prefix) will be included as query parameters in the URL.


    Parameters

    • optionalkeyword-onlylimit: int | None = None
    • optionalkeyword-onlyexclusive_start_key: str | None = None
    • optionalkeyword-onlycollection: str | None = None
    • optionalkeyword-onlyprefix: str | None = None
    • optionalkeyword-onlyexpires_in: timedelta | None = None

    Returns str

    The public key-value store keys URL.

delete

  • async delete(): None

delete_record

  • async delete_record(key): None

get

get_record

  • async get_record(key, signature): dict | None

get_record_as_bytes

  • async get_record_as_bytes(key, signature): dict | None

get_record_public_url

  • async get_record_public_url(key): str
  • Generate a URL that can be used to access key-value store record.

    If the client has permission to access the key-value store's URL signing key, the URL will include a signature to verify its authenticity.


    Parameters

    • key: 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.

iterate_keys

  • async iterate_keys(*, limit, collection, prefix, signature): AsyncIterator[KeyValueStoreKey]

  • Parameters

    • optionalkeyword-onlylimit: int | None = None

      Maximum number of keys to return. By default there is no limit.

    • optionalkeyword-onlycollection: str | None = None

      The name of the collection in store schema to list keys from.

    • optionalkeyword-onlyprefix: str | None = None

      The prefix of the keys to be listed.

    • optionalkeyword-onlysignature: str | None = None

      Signature used to access the items.

    Returns AsyncIterator[KeyValueStoreKey]

list_keys

  • async list_keys(*, limit, exclusive_start_key, collection, prefix, signature): ListOfKeys

  • Parameters

    • optionalkeyword-onlylimit: int | None = None

      Number of keys to be returned. Maximum value is 1000.

    • optionalkeyword-onlyexclusive_start_key: str | None = None

      All keys up to this one (including) are skipped from the result.

    • optionalkeyword-onlycollection: str | None = None

      The name of the collection in store schema to list keys from.

    • optionalkeyword-onlyprefix: str | None = None

      The prefix of the keys to be listed.

    • optionalkeyword-onlysignature: str | None = None

      Signature used to access the items.

    Returns ListOfKeys

    The list of keys in the key-value store matching the given arguments.

record_exists

  • async record_exists(key): bool

set_record

  • async set_record(key, value, content_type): None

stream_record

  • async stream_record(key, signature): AsyncIterator[dict | None]
  • Retrieve the given record from the key-value store, as a stream.

    https://docs.apify.com/api/v2#/reference/key-value-stores/record/get-record


    Parameters

    • key: str

      Key of the record to retrieve.

    • optionalsignature: str | None = None

      Signature used to access the items.

    Returns AsyncIterator[dict | None]

    The requested record as a context-managed streaming Response, or None, if the record does not exist.

update

Properties

resource_id

resource_id: str | None

Get the resource ID.