Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
- 'integrated/**'
- 'stl-preview-head/**'
- 'stl-preview-base/**'
pull_request:
branches-ignore:
- 'stl-preview-head/**'
- 'stl-preview-base/**'

jobs:
lint:
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "4.0.1"
".": "4.1.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 116
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-d7b617958673f6e5b94781a63ed79caed27014e5ca8bbf7e5e31b8f4d135aecb.yml
openapi_spec_hash: 66e9c2cd22385eed3ed507ee60aed4f5
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-9d6e0a988df83c0e2baa559ef57ec96981669a7a294de2188adb2cd6bbc0be8a.yml
openapi_spec_hash: 7f5e7221872d7ee799141f546c394f48
config_hash: 3c3524be9607afb24d2139ce26ce5389
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# Changelog

## 4.1.0 (2025-06-23)

Full Changelog: [v4.0.1...v4.1.0](https://github.com/orbcorp/orb-python/compare/v4.0.1...v4.1.0)

### Features

* **api:** api update ([145fb49](https://github.com/orbcorp/orb-python/commit/145fb49e263d98b69ebc44766fb21256792fb408))
* **api:** api update ([3e7554d](https://github.com/orbcorp/orb-python/commit/3e7554d9cb500e444e5e72c39324e8d478842dde))
* **api:** api update ([54a55d0](https://github.com/orbcorp/orb-python/commit/54a55d0284936e49b95b011203a57c1c844c34f9))
* **client:** add support for aiohttp ([afa214a](https://github.com/orbcorp/orb-python/commit/afa214aa4a2fc5db65335f063784df2e6e61292e))


### Bug Fixes

* **tests:** fix: tests which call HTTP endpoints directly with the example parameters ([9e77c70](https://github.com/orbcorp/orb-python/commit/9e77c705608f1f437d3487d1a8f3dbb383a7e533))


### Chores

* **ci:** enable for pull requests ([897e15e](https://github.com/orbcorp/orb-python/commit/897e15e361e1fd1a5941122f2fcbc025610c231b))
* **internal:** update conftest.py ([981e413](https://github.com/orbcorp/orb-python/commit/981e41335feb9bc86d7e465b12112854c5277c55))
* **readme:** update badges ([121b76c](https://github.com/orbcorp/orb-python/commit/121b76c47ed179936c95dd3a4033e25a49d68d8a))
* **tests:** add tests for httpx client instantiation & proxies ([41f738c](https://github.com/orbcorp/orb-python/commit/41f738c81995546912f43a79c61172557fe2153a))
* **tests:** skip some failing tests on the latest python versions ([b67c12c](https://github.com/orbcorp/orb-python/commit/b67c12ca7d3e2c860848de2a3018eb6b24a69c4d))


### Documentation

* **client:** fix httpx.Timeout documentation reference ([3d851a6](https://github.com/orbcorp/orb-python/commit/3d851a625d25c16779644d2bba29e0f8c9e87c7e))

## 4.0.1 (2025-06-12)

Full Changelog: [v4.0.0...v4.0.1](https://github.com/orbcorp/orb-python/compare/v4.0.0...v4.0.1)
Expand Down
39 changes: 37 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Orb Python API library

[![PyPI version](https://img.shields.io/pypi/v/orb-billing.svg)](https://pypi.org/project/orb-billing/)
[![PyPI version](<https://img.shields.io/pypi/v/orb-billing.svg?label=pypi%20(stable)>)](https://pypi.org/project/orb-billing/)

The Orb Python library provides convenient access to the Orb REST API from any Python 3.8+
application. The library includes type definitions for all request params and response fields,
Expand Down Expand Up @@ -68,6 +68,41 @@ asyncio.run(main())

Functionality between the synchronous and asynchronous clients is otherwise identical.

### With aiohttp

By default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.

You can enable this by installing `aiohttp`:

```sh
# install from PyPI
pip install orb-billing[aiohttp]
```

Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:

```python
import os
import asyncio
from orb import DefaultAioHttpClient
from orb import AsyncOrb


async def main() -> None:
async with AsyncOrb(
api_key=os.environ.get("ORB_API_KEY"), # This is the default and can be omitted
http_client=DefaultAioHttpClient(),
) as client:
customer = await client.customers.create(
email="[email protected]",
name="My Customer",
)
print(customer.id)


asyncio.run(main())
```

## Using types

Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:
Expand Down Expand Up @@ -257,7 +292,7 @@ client.with_options(max_retries=5).customers.create(
### Timeouts

By default requests time out after 1 minute. You can configure this with a `timeout` option,
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object:
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:

```python
from orb import Orb
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "orb-billing"
version = "4.0.1"
version = "4.1.0"
description = "The official Python library for the orb API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down Expand Up @@ -37,6 +37,8 @@ classifiers = [
Homepage = "https://github.com/orbcorp/orb-python"
Repository = "https://github.com/orbcorp/orb-python"

[project.optional-dependencies]
aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.6"]

[tool.rye]
managed = true
Expand Down
27 changes: 27 additions & 0 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,24 @@
# universal: false

-e file:.
aiohappyeyeballs==2.6.1
# via aiohttp
aiohttp==3.12.8
# via httpx-aiohttp
# via orb-billing
aiosignal==1.3.2
# via aiohttp
annotated-types==0.6.0
# via pydantic
anyio==4.4.0
# via httpx
# via orb-billing
argcomplete==3.1.2
# via nox
async-timeout==5.0.1
# via aiohttp
attrs==25.3.0
# via aiohttp
certifi==2023.7.22
# via httpcore
# via httpx
Expand All @@ -34,23 +45,33 @@ execnet==2.1.1
# via pytest-xdist
filelock==3.12.4
# via virtualenv
frozenlist==1.6.2
# via aiohttp
# via aiosignal
h11==0.14.0
# via httpcore
httpcore==1.0.2
# via httpx
httpx==0.28.1
# via httpx-aiohttp
# via orb-billing
# via respx
httpx-aiohttp==0.1.6
# via orb-billing
idna==3.4
# via anyio
# via httpx
# via yarl
importlib-metadata==7.0.0
iniconfig==2.0.0
# via pytest
markdown-it-py==3.0.0
# via rich
mdurl==0.1.2
# via markdown-it-py
multidict==6.4.4
# via aiohttp
# via yarl
mypy==1.14.1
mypy-extensions==1.0.0
# via mypy
Expand All @@ -65,6 +86,9 @@ platformdirs==3.11.0
# via virtualenv
pluggy==1.5.0
# via pytest
propcache==0.3.1
# via aiohttp
# via yarl
pydantic==2.10.3
# via orb-billing
pydantic-core==2.27.1
Expand Down Expand Up @@ -97,12 +121,15 @@ tomli==2.0.2
# via pytest
typing-extensions==4.12.2
# via anyio
# via multidict
# via mypy
# via orb-billing
# via pydantic
# via pydantic-core
# via pyright
virtualenv==20.24.5
# via nox
yarl==1.20.0
# via aiohttp
zipp==3.17.0
# via importlib-metadata
27 changes: 27 additions & 0 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,51 @@
# universal: false

-e file:.
aiohappyeyeballs==2.6.1
# via aiohttp
aiohttp==3.12.8
# via httpx-aiohttp
# via orb-billing
aiosignal==1.3.2
# via aiohttp
annotated-types==0.6.0
# via pydantic
anyio==4.4.0
# via httpx
# via orb-billing
async-timeout==5.0.1
# via aiohttp
attrs==25.3.0
# via aiohttp
certifi==2023.7.22
# via httpcore
# via httpx
distro==1.8.0
# via orb-billing
exceptiongroup==1.2.2
# via anyio
frozenlist==1.6.2
# via aiohttp
# via aiosignal
h11==0.14.0
# via httpcore
httpcore==1.0.2
# via httpx
httpx==0.28.1
# via httpx-aiohttp
# via orb-billing
httpx-aiohttp==0.1.6
# via orb-billing
idna==3.4
# via anyio
# via httpx
# via yarl
multidict==6.4.4
# via aiohttp
# via yarl
propcache==0.3.1
# via aiohttp
# via yarl
pydantic==2.10.3
# via orb-billing
pydantic-core==2.27.1
Expand All @@ -40,6 +64,9 @@ sniffio==1.3.0
# via orb-billing
typing-extensions==4.12.2
# via anyio
# via multidict
# via orb-billing
# via pydantic
# via pydantic-core
yarl==1.20.0
# via aiohttp
3 changes: 2 additions & 1 deletion src/orb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
DuplicateResourceCreation,
APIResponseValidationError,
)
from ._base_client import DefaultHttpxClient, DefaultAsyncHttpxClient
from ._base_client import DefaultHttpxClient, DefaultAioHttpClient, DefaultAsyncHttpxClient
from ._utils._logs import setup_logging as _setup_logging

__all__ = [
Expand Down Expand Up @@ -92,6 +92,7 @@
"DEFAULT_CONNECTION_LIMITS",
"DefaultHttpxClient",
"DefaultAsyncHttpxClient",
"DefaultAioHttpClient",
]

if not _t.TYPE_CHECKING:
Expand Down
22 changes: 22 additions & 0 deletions src/orb/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,24 @@ def __init__(self, **kwargs: Any) -> None:
super().__init__(**kwargs)


try:
import httpx_aiohttp
except ImportError:

class _DefaultAioHttpClient(httpx.AsyncClient):
def __init__(self, **_kwargs: Any) -> None:
raise RuntimeError("To use the aiohttp client you must have installed the package with the `aiohttp` extra")
else:

class _DefaultAioHttpClient(httpx_aiohttp.HttpxAiohttpClient): # type: ignore
def __init__(self, **kwargs: Any) -> None:
kwargs.setdefault("timeout", DEFAULT_TIMEOUT)
kwargs.setdefault("limits", DEFAULT_CONNECTION_LIMITS)
kwargs.setdefault("follow_redirects", True)

super().__init__(**kwargs)


if TYPE_CHECKING:
DefaultAsyncHttpxClient = httpx.AsyncClient
"""An alias to `httpx.AsyncClient` that provides the same defaults that this SDK
Expand All @@ -1312,8 +1330,12 @@ def __init__(self, **kwargs: Any) -> None:
This is useful because overriding the `http_client` with your own instance of
`httpx.AsyncClient` will result in httpx's defaults being used, not ours.
"""

DefaultAioHttpClient = httpx.AsyncClient
"""An alias to `httpx.AsyncClient` that changes the default HTTP transport to `aiohttp`."""
else:
DefaultAsyncHttpxClient = _DefaultAsyncHttpxClient
DefaultAioHttpClient = _DefaultAioHttpClient


class AsyncHttpxClientWrapper(DefaultAsyncHttpxClient):
Expand Down
2 changes: 1 addition & 1 deletion src/orb/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "orb"
__version__ = "4.0.1" # x-release-please-version
__version__ = "4.1.0" # x-release-please-version
Loading