You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api/async_client.md
+52-1Lines changed: 52 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,4 +10,55 @@
10
10
- __aenter__
11
11
- __aexit__
12
12
- close
13
-
heading_level: 2
13
+
heading_level: 2
14
+
15
+
## Basic Usage
16
+
17
+
```python
18
+
import asyncio
19
+
from bloomy import AsyncClient, ConfigurationError
20
+
21
+
asyncdefmain():
22
+
# Initialize with API key
23
+
asyncwith AsyncClient(api_key="your-api-key") as client:
24
+
users =await client.user.list()
25
+
26
+
# Custom base URL (for testing/staging)
27
+
asyncwith AsyncClient(
28
+
api_key="your-api-key",
29
+
base_url="https://staging.example.com/api/v1"
30
+
) as client:
31
+
users =await client.user.list()
32
+
33
+
# Custom timeout (in seconds)
34
+
asyncwith AsyncClient(api_key="your-api-key", timeout=60.0) as client:
35
+
users =await client.user.list()
36
+
37
+
# Handle missing API key
38
+
try:
39
+
client = AsyncClient()
40
+
except ConfigurationError as e:
41
+
print(f"Configuration error: {e}")
42
+
43
+
asyncio.run(main())
44
+
```
45
+
46
+
## Parameters
47
+
48
+
-**api_key** (str, optional): Your Bloom Growth API key. If not provided, will attempt to load from `BG_API_KEY` environment variable or `~/.bloomy/config.yaml`
49
+
-**base_url** (str, optional): Custom API endpoint. Defaults to `"https://app.bloomgrowth.com/api/v1"`
50
+
-**timeout** (float, optional): Request timeout in seconds. Defaults to `30.0`
51
+
52
+
## Exceptions
53
+
54
+
-**ConfigurationError**: Raised when no API key can be found from any source
55
+
56
+
## Context Manager
57
+
58
+
The AsyncClient supports async context manager protocol for automatic resource cleanup:
59
+
60
+
```python
61
+
asyncwith AsyncClient(api_key="your-api-key") as client:
62
+
users =await client.user.list()
63
+
# Client automatically closes when exiting the context
-**api_key** (str, optional): Your Bloom Growth API key. If not provided, will attempt to load from `BG_API_KEY` environment variable or `~/.bloomy/config.yaml`
40
+
-**base_url** (str, optional): Custom API endpoint. Defaults to `"https://app.bloomgrowth.com/api/v1"`
41
+
-**timeout** (float, optional): Request timeout in seconds. Defaults to `30.0`
42
+
43
+
## Exceptions
44
+
45
+
-**ConfigurationError**: Raised when no API key can be found from any source
46
+
47
+
## Context Manager
48
+
49
+
The Client supports context manager protocol for automatic resource cleanup:
50
+
51
+
```python
52
+
with Client(api_key="your-api-key") as client:
53
+
users = client.user.list()
54
+
# Client automatically closes when exiting the context
0 commit comments