Skip to content

Commit 4be6de8

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

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ Ready-to-run examples are available in `examples/`:
261261
- `examples/async_extract.py`
262262
- `examples/sync_web_search.py`
263263
- `examples/async_web_search.py`
264+
- `examples/sync_session_list.py`
264265

265266
## License
266267

examples/sync_session_list.py

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

0 commit comments

Comments
 (0)