Skip to content

Commit 6e4c55a

Browse files
Add asynchronous session listing usage example
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 4be6de8 commit 6e4c55a

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ Ready-to-run examples are available in `examples/`:
262262
- `examples/sync_web_search.py`
263263
- `examples/async_web_search.py`
264264
- `examples/sync_session_list.py`
265+
- `examples/async_session_list.py`
265266

266267
## License
267268

examples/async_session_list.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""
2+
Example: list sessions asynchronously with the Hyperbrowser SDK.
3+
4+
Run:
5+
export HYPERBROWSER_API_KEY="your_api_key"
6+
python3 examples/async_session_list.py
7+
"""
8+
9+
import asyncio
10+
11+
from hyperbrowser import AsyncHyperbrowser
12+
from hyperbrowser.models import SessionListParams
13+
14+
15+
async def main() -> None:
16+
async with AsyncHyperbrowser() as client:
17+
response = await client.sessions.list(
18+
SessionListParams(
19+
page=1,
20+
limit=5,
21+
)
22+
)
23+
24+
print(f"Success: {response.success}")
25+
print(f"Returned sessions: {len(response.data)}")
26+
for session in response.data:
27+
print(f"- {session.id} ({session.status})")
28+
29+
30+
if __name__ == "__main__":
31+
asyncio.run(main())

0 commit comments

Comments
 (0)