Official Libraries
- @unkey/api
- @unkey/ratelimit
- @unkey/nextjs
- @unkey/hono
- @unkey/cache
- unkey-go
- unkey.py
- Elixir
- Nuxt
- Rust
- Springboot
List Keys
Get a list of keys belonging to an API
const listKeys = await unkey.apis.listKeys({
apiId: "api_QUGih1EMtBy9eSSf3vujmF",
limit: 100,
})
console.log(listKeys)
{
"keys": [
{
"id": "key_HPnfviesBEKHnZBFFiY4fg",
"apiId": "api_QUGih1EMtBy9eSSf3vujmF",
"workspaceId": "ws_o17fS1LvwtRswPdncAcUM",
"start": "key_Crg",
"createdAt": 1687642066782,
"expires": null,
"ratelimit": {
"type": "fast",
"limit": 11,
"refillRate": 11,
"refillInterval": 11
}
},
...
],
"total": 4
}
Request
The ID of the api you want to retrieve.
Limit the number of returned keys, the maximum is 100.
Specify an offset for pagination.
Example:
An offset of 4
will skip the first 4 keys and return keys starting at the 5th position.
Filter by ownerId
.
If provided, this will only return keys where the ownerId
matches.
Response
The unique key id, use this to reference the key directly when fetching or revoking.
The API id where this key belongs to.
The workspace id where this key belongs to.
The first few characters of the key. This can be useful when displaying it your users, so they can match it.
The name you gave this key.
Your user’s Id. This will provide a link between Unkey and your customer record.
When validating a key, we will return this back to you, so you can clearly identify your user from their api key.
This is a place for dynamic meta data, anything that feels useful for you should go here
Example:
{
"billingTier": "PRO",
"trialEnds": "2023-06-16T17:16:37.161Z"
}
When the key was created, unix timestamp in milliseconds.
If set, this is when the key ceases to exist, unix timestamp in milliseconds. Once keys expire they will automatically be deleted and are no longer valid.
How many more times this key can be used.
The ratelimit of this key, if configured.
How many keys in total there are in this API. Useful to paginate through this endpoint.
const listKeys = await unkey.apis.listKeys({
apiId: "api_QUGih1EMtBy9eSSf3vujmF",
limit: 100,
})
console.log(listKeys)
{
"keys": [
{
"id": "key_HPnfviesBEKHnZBFFiY4fg",
"apiId": "api_QUGih1EMtBy9eSSf3vujmF",
"workspaceId": "ws_o17fS1LvwtRswPdncAcUM",
"start": "key_Crg",
"createdAt": 1687642066782,
"expires": null,
"ratelimit": {
"type": "fast",
"limit": 11,
"refillRate": 11,
"refillInterval": 11
}
},
...
],
"total": 4
}
Was this page helpful?
const listKeys = await unkey.apis.listKeys({
apiId: "api_QUGih1EMtBy9eSSf3vujmF",
limit: 100,
})
console.log(listKeys)
{
"keys": [
{
"id": "key_HPnfviesBEKHnZBFFiY4fg",
"apiId": "api_QUGih1EMtBy9eSSf3vujmF",
"workspaceId": "ws_o17fS1LvwtRswPdncAcUM",
"start": "key_Crg",
"createdAt": 1687642066782,
"expires": null,
"ratelimit": {
"type": "fast",
"limit": 11,
"refillRate": 11,
"refillInterval": 11
}
},
...
],
"total": 4
}