KeyValueStoreClient
Hierarchy
- ResourceClient
- KeyValueStoreClient
Index
Properties
inheritedapifyClient
inheritedbaseUrl
inheritedhttpClient
optionalinheritedid
optionalinheritedparams
inheritedpublicBaseUrl
inheritedresourcePath
optionalinheritedsafeId
inheritedurl
Methods
createKeysPublicUrl
Generates a public URL for accessing the list of keys in the key-value store.
If the client has permission to access the key-value store's URL signing key, the URL will include a cryptographic signature which allows access without authentication.
Parameters
options: KeyValueClientCreateKeysUrlOptions = {}
URL generation options (extends all options from listKeys)
Returns Promise<string>
A public URL string for accessing the keys list
delete
Deletes the key-value store.
Returns Promise<void>
deleteRecord
Deletes a record from the key-value store.
Parameters
key: string
The record key to delete
Returns Promise<void>
get
Gets the key-value store object from the Apify API.
Returns Promise<undefined | KeyValueStore>
The KeyValueStore object, or
undefinedif it does not exist
getRecord
You can use the
bufferoption to get the value in a Buffer (Node.js) or ArrayBuffer (browser) format. In Node.js (not in browser) you can also use thestreamoption to get a Readable stream.When the record does not exist, the function resolves to
undefined. It does NOT resolve to aKeyValueStorerecord with anundefinedvalue.Parameters
key: string
Returns Promise<undefined | KeyValueStoreRecord<JsonValue>>
getRecordPublicUrl
Generates a public URL for accessing a specific record in the key-value store.
If the client has permission to access the key-value store's URL signing key, the URL will include a cryptographic signature for authenticated access without requiring an API token.
Parameters
key: string
The record key
Returns Promise<string>
A public URL string for accessing the record
listKeys
Lists all keys in the key-value store.
Returns a paginated list of all record keys in the store. Use pagination parameters to retrieve large lists efficiently.
Parameters
options: KeyValueClientListKeysOptions = {}
Listing options
Returns Promise<KeyValueClientListKeysResult> & AsyncIterable<KeyValueListItem, any, any>
Object containing
itemsarray of key metadata, pagination info (count,limit,isTruncated,nextExclusiveStartKey)
recordExists
Tests whether a record with the given key exists in the key-value store without retrieving its value.
This is more efficient than getRecord when you only need to check for existence.
Parameters
key: string
The record key to check
Returns Promise<boolean>
trueif the record exists,falseif it does not
setRecord
Stores a record in the key-value store.
The record value can be any JSON-serializable object, a string, or a Buffer/Stream. The content type is automatically determined based on the value type, but can be overridden using the
contentTypeproperty.Note about streams: If the value is a stream object (has
.pipeand.onmethods), the upload cannot be retried on failure or follow redirects. For reliable uploads, buffer the entire stream into memory first.Parameters
record: KeyValueStoreRecord<JsonValue>
The record to store
options: KeyValueStoreRecordOptions = {}
Storage options
Returns Promise<void>
update
Updates the key-value store with specified fields.
Parameters
newFields: KeyValueClientUpdateOptions
Fields to update in the key-value store
Returns Promise<KeyValueStore>
The updated KeyValueStore object
Client for managing a specific key-value store.
Key-value stores are used to store arbitrary data records or files. Each record is identified by a unique key and can contain any type of data. This client provides methods to get, set, and delete records, list keys, and manage the store.
https://docs.apify.com/platform/storage/key-value-store