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
access_token=os.environ.get("BEEPER_ACCESS_TOKEN"), # This is the default and can be omitted
34
34
)
35
35
36
-
user_info = client.token.info()
37
-
print(user_info.sub)
36
+
page = client.chats.search(
37
+
include_muted=True,
38
+
limit=3,
39
+
type="single",
40
+
)
41
+
print(page.items)
38
42
```
39
43
40
44
While you can provide a `access_token` keyword argument,
@@ -57,8 +61,12 @@ client = AsyncBeeperDesktop(
57
61
58
62
59
63
asyncdefmain() -> None:
60
-
user_info =await client.token.info()
61
-
print(user_info.sub)
64
+
page =await client.chats.search(
65
+
include_muted=True,
66
+
limit=3,
67
+
type="single",
68
+
)
69
+
print(page.items)
62
70
63
71
64
72
asyncio.run(main())
@@ -90,8 +98,12 @@ async def main() -> None:
90
98
access_token="My Access Token",
91
99
http_client=DefaultAioHttpClient(),
92
100
) as client:
93
-
user_info =await client.token.info()
94
-
print(user_info.sub)
101
+
page =await client.chats.search(
102
+
include_muted=True,
103
+
limit=3,
104
+
type="single",
105
+
)
106
+
print(page.items)
95
107
96
108
97
109
asyncio.run(main())
@@ -106,6 +118,101 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ
106
118
107
119
Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.
108
120
121
+
## Pagination
122
+
123
+
List methods in the Beeper Desktop API are paginated.
124
+
125
+
This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:
Nested parameters are dictionaries, typed using `TypedDict`, for example:
203
+
204
+
```python
205
+
from beeper_desktop_api import BeeperDesktop
206
+
207
+
client = BeeperDesktop()
208
+
209
+
base_response = client.chats.reminders.create(
210
+
chat_id="!NCdzlIaMjZUmvmvyHU:beeper.com",
211
+
reminder={"remind_at_ms": 0},
212
+
)
213
+
print(base_response.reminder)
214
+
```
215
+
109
216
## Handling errors
110
217
111
218
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `beeper_desktop_api.APIConnectionError` is raised.
@@ -122,7 +229,10 @@ from beeper_desktop_api import BeeperDesktop
122
229
client = BeeperDesktop()
123
230
124
231
try:
125
-
client.token.info()
232
+
client.messages.send(
233
+
chat_id="1229391",
234
+
text="Hello! Just checking in on the project status.",
235
+
)
126
236
except beeper_desktop_api.APIConnectionError as e:
127
237
print("The server could not be reached")
128
238
print(e.__cause__) # an underlying Exception, likely raised within httpx.
token= response.parse() # get the object that `token.info()` would have returned
236
-
print(token.sub)
345
+
account= response.parse() # get the object that `accounts.list()` would have returned
346
+
print(account)
237
347
```
238
348
239
349
These methods return an [`APIResponse`](https://github.com/beeper/desktop-api-python/tree/main/src/beeper_desktop_api/_response.py) object.
@@ -247,7 +357,7 @@ The above interface eagerly reads the full response body when you make the reque
247
357
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
248
358
249
359
```python
250
-
with client.token.with_streaming_response.info() as response:
360
+
with client.accounts.with_streaming_response.list() as response:
0 commit comments