ApifyClient.API.KeyValueStores.Records (apify_client v1.0.0)

Copy Markdown View Source

Provides API endpoints related to api/key value stores/records

Summary

Functions

Delete key-value store record

Get key-value store record

Check if key-value store record exists

Download key-value store records

Functions

delete(store_id, record_key, opts \\ [])

@spec delete(store_id :: String.t(), record_key :: String.t(), opts :: keyword()) ::
  :ok | {:error, ApifyClient.Error.t()}

Delete key-value store record

Removes a record specified by a key from the key-value store.

get(store_id, record_key, opts \\ [])

@spec get(store_id :: String.t(), record_key :: String.t(), opts :: keyword()) ::
  {:ok, any()} | {:error, ApifyClient.Error.t()}

Get key-value store record

Gets a value stored in the key-value store under a specific key.

The response body has the same Content-Encoding header as it was set in Set key-value store record.

If the request does not define the Accept-Encoding HTTP header with the right encoding, the record will be decompressed.

Most HTTP clients support decompression by default. After using the HTTP client with decompression support, the Accept-Encoding header is set by the client and body is decompressed automatically.

Please note that for security reasons, Apify API can perform small modifications to HTML documents before they are served via this endpoint. To fetch the raw HTML content without any modifications, use the attachment query parameter.

Options

  • attachment: If true or 1, the response will be served with Content-Disposition: attachment header, causing web browsers to offer downloading HTML records instead of displaying them.

  • signature: Signature used for the access.

head(store_id, record_key, opts \\ [])

@spec head(store_id :: String.t(), record_key :: String.t(), opts :: keyword()) ::
  :ok | {:error, ApifyClient.Error.t()}

Check if key-value store record exists

Check if a value is stored in the key-value store under a specific key.

list(store_id, opts \\ [])

@spec list(store_id :: String.t(), opts :: keyword()) ::
  {:ok, binary()} | {:error, ApifyClient.Error.t()}

Download key-value store records

Downloads all records from the key-value store as a ZIP archive. Each record is stored as a separate file in the archive, with the filename equal to the record key.

You can optionally filter the records by collection or prefix to download only a subset of the store.

Options

  • collection: If specified, only records belonging to a specific collection from the key-value store schema. The key-value store need to have a schema defined for this parameter to work.

  • prefix: If specified, only records whose key starts with the given prefix are included in the archive.

  • signature: Signature used for the access.

update(store_id, record_key, body, opts \\ [])

@spec update(
  store_id :: String.t(),
  record_key :: String.t(),
  body :: any(),
  opts :: keyword()
) ::
  {:ok, map() | nil} | {:error, ApifyClient.Error.t()}

Set key-value store record

Stores a value under a specific key to the key-value store.

The value is passed as the PUT payload and it is stored with a MIME content type defined by the Content-Type header and with encoding defined by the Content-Encoding header.

To save bandwidth, storage, and speed up your upload, send the request payload compressed with Gzip compression and add the Content-Encoding: gzip header. It is possible to set up another compression type with Content-Encoding request header.

Below is a list of supported Content-Encoding types.

  • Brotli compression: Content-Encoding: br
  • Gzip compression: Content-Encoding: gzip
  • Zstandard compression: Content-Encoding: zstd
  • Deflate compression: Content-Encoding: deflate

Request Body

Content Types: */*, application/json