Skip to main content
Version: 2.7

KeyValueStoreClient

Hierarchy

  • ResourceClient
    • KeyValueStoreClient

Index

Properties

apifyClient

apifyClient: ApifyClient

baseUrl

baseUrl: string

httpClient

httpClient: HttpClient

optionalid

id?: string

optionalparams

params?: Record<string, unknown>

resourcePath

resourcePath: string

optionalsafeId

safeId?: string

url

url: string

Methods

delete

  • delete(): Promise<void>

deleteRecord

  • deleteRecord(key): Promise<void>

get

  • get(): Promise<undefined | KeyValueStore>

getRecord

  • getRecord(key): Promise<undefined | KeyValueStoreRecord<JsonValue>>
  • getRecord<Options>(key, options): Promise<undefined | KeyValueStoreRecord<ReturnTypeFromOptions<Options>>>
  • You can use the buffer option to get the value in a Buffer (Node.js) or ArrayBuffer (browser) format. In Node.js (not in browser) you can also use the stream option to get a Readable stream.

    When the record does not exist, the function resolves to undefined. It does NOT resolve to a KeyValueStore record with an undefined value. https://docs.apify.com/api/v2#/reference/key-value-stores/record/get-record


    Parameters

    • key: string

    Returns Promise<undefined | KeyValueStoreRecord<JsonValue>>

listKeys

  • listKeys(options): Promise<KeyValueClientListKeysResult>

setRecord

  • setRecord(record): Promise<void>
  • The value in the record can be a stream object (detected by having the .pipe and .on methods). However, note that in that case following redirects or retrying the request if it fails (for example due to rate limiting) isn't possible. If you want to keep that behavior, you need to collect the whole stream contents into a Buffer and then send the full buffer. See this StackOverflow answer for an example how to do that.

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


    Parameters

    • record: KeyValueStoreRecord<JsonValue>

    Returns Promise<void>

update

  • update(newFields): Promise<KeyValueStore>