Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow is triggered when a GitHub release is created.
# It can also be run manually to re-publish to PyPI in case it failed for some reason.
# You can run this workflow by navigating to https://www.github.com/beeper/desktop-api-python/actions/workflows/publish-pypi.yml
name: Publish PyPI
on:
workflow_dispatch:

release:
types: [published]

jobs:
publish:
name: publish
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install Rye
run: |
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: '0.44.0'
RYE_INSTALL_OPTION: '--yes'

- name: Publish to PyPI
run: |
bash ./bin/publish-pypi
env:
PYPI_TOKEN: ${{ secrets.BEEPER_DESKTOP_PYPI_TOKEN || secrets.PYPI_TOKEN }}
21 changes: 21 additions & 0 deletions .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Release Doctor
on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
release_doctor:
name: release doctor
runs-on: ubuntu-latest
if: github.repository == 'beeper/desktop-api-python' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')

steps:
- uses: actions/checkout@v4

- name: Check release environment
run: |
bash ./bin/check-release-environment
env:
PYPI_TOKEN: ${{ secrets.BEEPER_DESKTOP_PYPI_TOKEN || secrets.PYPI_TOKEN }}
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "4.1.295"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 1
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/beeper%2Fbeeper-desktop-api-8c712fe19f280b0b89ecc8a3ce61e9f6b165cee97ce33f66c66a7a5db339c755.yml
openapi_spec_hash: 1ea71129cc1a1ccc3dc8a99566082311
config_hash: def03aa92de3408ec65438763617f5c7
configured_endpoints: 15
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/beeper%2Fbeeper-desktop-api-0763b61997721da6f4514241bf0f7bb5f7a88c7298baf0f1b2d58036aaf7e2f1.yml
openapi_spec_hash: 5158475919c04bb52fb03c6a4582188d
config_hash: 5fa7ded4bfdffe4cc1944a819da87f9f
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Changelog

## 4.1.295 (2025-10-16)

Full Changelog: [v0.0.1...v4.1.295](https://github.com/beeper/desktop-api-python/compare/v0.0.1...v4.1.295)

### Features

* **api:** bump for new endpoints ([f63e0e4](https://github.com/beeper/desktop-api-python/commit/f63e0e48e35789609f9c589684ab03a9ca97b28d))
* **api:** manual updates ([86218ff](https://github.com/beeper/desktop-api-python/commit/86218ff03f8a0cd42050b0c3babdf78178fda3da))
* **api:** manual updates ([0fcd71f](https://github.com/beeper/desktop-api-python/commit/0fcd71f9951498d349fb816b42dc21347f3ab5dc))
* **api:** manual updates ([dce7124](https://github.com/beeper/desktop-api-python/commit/dce712498ff2678222fd203118e7bb91f13ccfc5))
* **api:** manual updates ([48b4b7f](https://github.com/beeper/desktop-api-python/commit/48b4b7f01064d016b84e954f9aa9f327863cc1d3))
* **api:** manual updates ([c9f3b2d](https://github.com/beeper/desktop-api-python/commit/c9f3b2d3a7fb7e2ce3b30de215497079fff3aca9))
* **api:** manual updates ([7c655fb](https://github.com/beeper/desktop-api-python/commit/7c655fb94ba070083173c15a501be7a0f119a38b))
* **api:** manual updates ([88bce73](https://github.com/beeper/desktop-api-python/commit/88bce73dfef13b6a1cdef0749dc3078af97255e4))
* **api:** manual updates ([1ea87ff](https://github.com/beeper/desktop-api-python/commit/1ea87ff08b4b50541e3c26bef6f4bd581af6324c))
* **api:** manual updates ([b1ba1c0](https://github.com/beeper/desktop-api-python/commit/b1ba1c0584b99ab402f7c1643c13c19881baa600))
* **api:** manual updates ([545ed69](https://github.com/beeper/desktop-api-python/commit/545ed69d7251f47a309f2f46ee4f3b8e4cf1cc60))
* **api:** remove limit from list routes ([d5cb6c2](https://github.com/beeper/desktop-api-python/commit/d5cb6c2ee132bc3d558552df145082396c80521c))


### Chores

* configure new SDK language ([d0b2ca6](https://github.com/beeper/desktop-api-python/commit/d0b2ca6bd2e9331cd42fe5143e0f94861502f11f))
* configure new SDK language ([d11b464](https://github.com/beeper/desktop-api-python/commit/d11b4641e572db6ceb07bb4b9d47b97beadd9253))
* **internal:** detect missing future annotations with ruff ([5e05845](https://github.com/beeper/desktop-api-python/commit/5e058450070fedbd9730bd6ec57fa392974d09e1))
* update SDK settings ([8f54b9a](https://github.com/beeper/desktop-api-python/commit/8f54b9a9ed423fa039b5e59131cd69d7fa809d9e))
* update SDK settings ([0d38dfa](https://github.com/beeper/desktop-api-python/commit/0d38dfa50d797ff879df6d5c633bbcb43c3a98fd))
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ If you’d like to use the repository from source, you can either install from g
To install via git:

```sh
$ pip install git+ssh://[email protected]/stainless-sdks/beeper-desktop-api-python.git
$ pip install git+ssh://[email protected]/beeper/desktop-api-python.git
```

Alternatively, you can build from source and install the wheel file:
Expand Down Expand Up @@ -120,7 +120,7 @@ the changes aren't made through the automated pipeline, you may want to make rel

### Publish with a GitHub workflow

You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/stainless-sdks/beeper-desktop-api-python/actions/workflows/publish-pypi.yml). This requires a setup organization or repository secret to be set up.
You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/beeper/desktop-api-python/actions/workflows/publish-pypi.yml). This requires a setup organization or repository secret to be set up.

### Publish manually

Expand Down
149 changes: 126 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@ The REST API documentation can be found on [developers.beeper.com](https://devel
## Installation

```sh
# install from this staging repo
pip install git+ssh://[email protected]/stainless-sdks/beeper-desktop-api-python.git
# install from PyPI
pip install beeper_desktop_api
```

> [!NOTE]
> Once this package is [published to PyPI](https://www.stainless.com/docs/guides/publish), this will become: `pip install beeper_desktop_api`

## Usage

The full API of this library can be found in [api.md](api.md).
Expand All @@ -33,8 +30,12 @@ client = BeeperDesktop(
access_token=os.environ.get("BEEPER_ACCESS_TOKEN"), # This is the default and can be omitted
)

user_info = client.token.info()
print(user_info.sub)
page = client.chats.search(
include_muted=True,
limit=3,
type="single",
)
print(page.items)
```

While you can provide a `access_token` keyword argument,
Expand All @@ -57,8 +58,12 @@ client = AsyncBeeperDesktop(


async def main() -> None:
user_info = await client.token.info()
print(user_info.sub)
page = await client.chats.search(
include_muted=True,
limit=3,
type="single",
)
print(page.items)


asyncio.run(main())
Expand All @@ -73,8 +78,8 @@ By default, the async client uses `httpx` for HTTP requests. However, for improv
You can enable this by installing `aiohttp`:

```sh
# install from this staging repo
pip install 'beeper_desktop_api[aiohttp] @ git+ssh://[email protected]/stainless-sdks/beeper-desktop-api-python.git'
# install from PyPI
pip install beeper_desktop_api[aiohttp]
```

Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:
Expand All @@ -90,8 +95,12 @@ async def main() -> None:
access_token="My Access Token",
http_client=DefaultAioHttpClient(),
) as client:
user_info = await client.token.info()
print(user_info.sub)
page = await client.chats.search(
include_muted=True,
limit=3,
type="single",
)
print(page.items)


asyncio.run(main())
Expand All @@ -106,6 +115,100 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ

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`.

## Pagination

List methods in the Beeper Desktop API are paginated.

This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:

```python
from beeper_desktop_api import BeeperDesktop

client = BeeperDesktop()

all_messages = []
# Automatically fetches more pages as needed.
for message in client.messages.search(
account_ids=["local-telegram_ba_QFrb5lrLPhO3OT5MFBeTWv0x4BI"],
limit=10,
query="deployment",
):
# Do something with message here
all_messages.append(message)
print(all_messages)
```

Or, asynchronously:

```python
import asyncio
from beeper_desktop_api import AsyncBeeperDesktop

client = AsyncBeeperDesktop()


async def main() -> None:
all_messages = []
# Iterate through items across all pages, issuing requests as needed.
async for message in client.messages.search(
account_ids=["local-telegram_ba_QFrb5lrLPhO3OT5MFBeTWv0x4BI"],
limit=10,
query="deployment",
):
all_messages.append(message)
print(all_messages)


asyncio.run(main())
```

Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:

```python
first_page = await client.messages.search(
account_ids=["local-telegram_ba_QFrb5lrLPhO3OT5MFBeTWv0x4BI"],
limit=10,
query="deployment",
)
if first_page.has_next_page():
print(f"will fetch next page using these details: {first_page.next_page_info()}")
next_page = await first_page.get_next_page()
print(f"number of items we just fetched: {len(next_page.items)}")

# Remove `await` for non-async usage.
```

Or just work directly with the returned data:

```python
first_page = await client.messages.search(
account_ids=["local-telegram_ba_QFrb5lrLPhO3OT5MFBeTWv0x4BI"],
limit=10,
query="deployment",
)

print(f"next page cursor: {first_page.oldest_cursor}") # => "next page cursor: ..."
for message in first_page.items:
print(message.id)

# Remove `await` for non-async usage.
```

## Nested params

Nested parameters are dictionaries, typed using `TypedDict`, for example:

```python
from beeper_desktop_api import BeeperDesktop

client = BeeperDesktop()

client.chats.reminders.create(
chat_id="!NCdzlIaMjZUmvmvyHU:beeper.com",
reminder={"remind_at_ms": 0},
)
```

## Handling errors

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.
Expand All @@ -122,7 +225,7 @@ from beeper_desktop_api import BeeperDesktop
client = BeeperDesktop()

try:
client.token.info()
client.accounts.list()
except beeper_desktop_api.APIConnectionError as e:
print("The server could not be reached")
print(e.__cause__) # an underlying Exception, likely raised within httpx.
Expand Down Expand Up @@ -165,7 +268,7 @@ client = BeeperDesktop(
)

# Or, configure per-request:
client.with_options(max_retries=5).token.info()
client.with_options(max_retries=5).accounts.list()
```

### Timeouts
Expand All @@ -188,7 +291,7 @@ client = BeeperDesktop(
)

# Override per-request:
client.with_options(timeout=5.0).token.info()
client.with_options(timeout=5.0).accounts.list()
```

On timeout, an `APITimeoutError` is thrown.
Expand Down Expand Up @@ -229,16 +332,16 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
from beeper_desktop_api import BeeperDesktop

client = BeeperDesktop()
response = client.token.with_raw_response.info()
response = client.accounts.with_raw_response.list()
print(response.headers.get('X-My-Header'))

token = response.parse() # get the object that `token.info()` would have returned
print(token.sub)
account = response.parse() # get the object that `accounts.list()` would have returned
print(account)
```

These methods return an [`APIResponse`](https://github.com/stainless-sdks/beeper-desktop-api-python/tree/main/src/beeper_desktop_api/_response.py) object.
These methods return an [`APIResponse`](https://github.com/beeper/desktop-api-python/tree/main/src/beeper_desktop_api/_response.py) object.

The async client returns an [`AsyncAPIResponse`](https://github.com/stainless-sdks/beeper-desktop-api-python/tree/main/src/beeper_desktop_api/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
The async client returns an [`AsyncAPIResponse`](https://github.com/beeper/desktop-api-python/tree/main/src/beeper_desktop_api/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.

#### `.with_streaming_response`

Expand All @@ -247,7 +350,7 @@ The above interface eagerly reads the full response body when you make the reque
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.

```python
with client.token.with_streaming_response.info() as response:
with client.accounts.with_streaming_response.list() as response:
print(response.headers.get("X-My-Header"))

for line in response.iter_lines():
Expand Down Expand Up @@ -342,7 +445,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/beeper-desktop-api-python/issues) with questions, bugs, or suggestions.
We are keen for your feedback; please open an [issue](https://www.github.com/beeper/desktop-api-python/issues) with questions, bugs, or suggestions.

### Determining the installed version

Expand Down
Loading