Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/content/docs/kv/api/list-keys.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/).
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/).