KeyValueStore
Index
Methods
drop
{"content": ["Remove the key-value store either from the Apify cloud storage or from the local directory."]}
Returns None
get_public_url
{"content": ["Get a URL for the given key that may be used to publicly access the value in the remote key-value store.\n", {"
Parameters
key: str
Returns str
get_value
{"content": ["Get a value from the key-value store.\n", {"
Parameters
key: str
default_value: T | None = None
Returns T | None
iterate_keys
{"content": ["Iterate over the keys in the key-value store.\n", {"
Parameters
exclusive_start_key: str | None = None
Returns AsyncIterator[IterateKeysTuple]
open
{"content": ["Open a key-value store.\n\nKey-value stores are used to store records or files, along with their MIME content type.\nThe records are stored and retrieved using a unique key.\nThe actual data is stored either on a local filesystem or in the Apify cloud.\n", {"
Parameters
keyword-onlyid: str | None = None
keyword-onlyname: str | None = None
keyword-onlyforce_cloud: bool = False
keyword-onlyconfig: Configuration | None = None
Returns KeyValueStore
set_value
{"content": ["Set or delete a value in the key-value store.\n", {"
Parameters
key: str
value: Any
content_type: str | None = None
Returns None
{"content": ["The
KeyValueStoreclass represents a key-value store.\n\nYou can imagine it as a simple data storage that is used\nfor saving and reading data records or files. Each data record is\nrepresented by a unique key and associated with a MIME content type.\n\nDo not instantiate this class directly, use theActor.open_key_value_store()function instead.\n\nEach crawler run is associated with a default key-value store, which is created exclusively\nfor the run. By convention, the crawler input and output are stored into the\ndefault key-value store under theINPUTandOUTPUTkey, respectively.\nTypically, input and output are JSON files, although it can be any other format.\nTo access the default key-value store directly, you can use the\nKeyValueStore.get_valueandKeyValueStore.set_valueconvenience functions.\n\nKeyValueStorestores its data either on local disk or in the Apify cloud,\ndepending on whether theAPIFY_LOCAL_STORAGE_DIRorAPIFY_TOKENenvironment variables are set.\n\nIf theAPIFY_LOCAL_STORAGE_DIRenvironment variable is set, the data is stored in\nthe local directory in the following files:\n``\n{APIFY_LOCAL_STORAGE_DIR}/key_value_stores/{STORE_ID}/{INDEX}.{EXT}\n``", "Note that{STORE_ID}is the name or ID of the key-value store. The default key-value store has ID:default,\nunless you override it by setting theAPIFY_DEFAULT_KEY_VALUE_STORE_IDenvironment variable.\nThe{KEY}is the key of the record and{EXT}corresponds to the MIME content type of the data value.\n\nIf theAPIFY_TOKENenvironment variable is set butAPIFY_LOCAL_STORAGE_DIRis not, the data is stored in the\nApify Key-value store cloud storage."]}