diff --git a/src/content/docs/kv/api/list-keys.mdx b/src/content/docs/kv/api/list-keys.mdx index eb912d649bba819..08ae0945bb7fe2d 100644 --- a/src/content/docs/kv/api/list-keys.mdx +++ b/src/content/docs/kv/api/list-keys.mdx @@ -124,6 +124,13 @@ export default { }; ``` + +```python +async fetch(request, env, ctx): + value = await env.NAMESPACE.list(prefix = "user:1:") + return Response(value.keys) +``` + This will return all keys starting with the `"user:1:"` prefix. ### Ordering @@ -159,4 +166,4 @@ await NAMESPACE.put(key, "", { ``` ## Other methods to access KV -You can also [list keys on the command line with Wrangler](/kv/reference/kv-commands/#kv-namespace-list) or [with the REST API](/api/resources/kv/subresources/namespaces/subresources/keys/methods/list/). \ No newline at end of file +You can also [list keys on the command line with Wrangler](/kv/reference/kv-commands/#kv-namespace-list) or [with the REST API](/api/resources/kv/subresources/namespaces/subresources/keys/methods/list/).