Skip to content

Commit

Permalink
Update python SDK docs (#690)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonxslays authored Dec 15, 2023
1 parent b86b8b7 commit 4fe3509
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
4 changes: 3 additions & 1 deletion apps/docs/libraries/py/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async def main() -> None:
client = unkey.Client(api_key=os.environ["API_KEY"])
await client.start()

result = await client.keys.verify_key("prefix_123ABC")
result = await client.keys.verify_key("prefix_123ABC", "api_345")

if result.is_ok:
data = result.unwrap()
Expand All @@ -59,6 +59,8 @@ if __name__ == "__main__":

```

Other examples may omit the async main function, setup, and imports for brevity.

## Guides

- [Installation](https://jonxslays.github.io/unkey.py/stable/getting-started/installation/)
Expand Down
31 changes: 23 additions & 8 deletions apps/docs/libraries/py/services/apis.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,27 @@ result = await client.apis.get_api("api_123")
Retrieve a paginated list of api keys for a given api ID.

```py
# retrieve the first 100 api keys for this api
result = await client.apis.list_keys("api_123")

# retrieve the second 100 keys for this api
result = await client.apis.list_keys("api_123", offset=100)

# retrieve the second 10 api keys
result = await client.apis.list_keys("api_123", offset=10, limit=10)
# Page through keys 10 at a time
exhausted = False
cursor = unkey.UNDEFINED # Must import unkey

while not exhausted:
# Fetch the next 10 keys
result = await client.apis.list_keys("api_123", limit=10, cursor=cursor)

if result.is_ok:
data = result.unwrap()

if not data.cursor:
# No cursor means no more keys exist after this page
exhausted = True
continue

cursor = data.cursor
print(data.keys)
await asyncio.sleep(1) # Sleep 1 second, must import asyncio
else:
# Something went wrong
print(result.unwrap_err())
exhausted = True
```
11 changes: 10 additions & 1 deletion apps/docs/libraries/py/services/keys.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ result = await client.keys.create_key(
Verifies that a key is valid, and within ratelimit.

```py
result = await client.keys.verify_key("test_123DEF")
result = await client.keys.verify_key("test_123DEF", "api_789")
```

## Revoke key
Expand All @@ -46,3 +46,12 @@ result = await client.keys.update_key(
expires=None,
)
```

## Get key

Retrieves details for the key with the given ID.

```py
result = await client.keys.get_key("key_789JKL")
```

0 comments on commit 4fe3509

Please sign in to comment.