Skip to content
Start here

Read key-value pair

kv.namespaces.values.get(strkey_name, ValueGetParams**kwargs) -> BinaryResponseContent
GET/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}

Returns the value associated with the given key in the given namespace. Use URL-encoding to use special characters (for example, :, !, %) in the key name. If the KV-pair is set to expire at some point, the expiration time as measured in seconds since the UNIX epoch will be returned in the expiration response header.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Workers KV Storage WriteWorkers KV Storage Read
ParametersExpand Collapse
account_id: str

Identifier.

maxLength32
namespace_id: str

Namespace identifier tag.

maxLength32
key_name: str

A key’s name. The name may be at most 512 bytes. All printable, non-whitespace characters are valid. Use percent-encoding to define key names as part of a URL.

maxLength512
ReturnsExpand Collapse
BinaryResponseContent

Read key-value pair

import os
from cloudflare import Cloudflare

client = Cloudflare(
    api_token=os.environ.get("CLOUDFLARE_API_TOKEN"),  # This is the default and can be omitted
)
value = client.kv.namespaces.values.get(
    key_name="My-Key",
    account_id="023e105f4ecef8ad9ca31a8372d0c353",
    namespace_id="0f2ac74b498b48028cb68387c421e279",
)
print(value)
content = value.read()
print(content)
Returns Examples