|
1 | 1 | # Steel Python API library |
2 | 2 |
|
3 | | -[](https://pypi.org/project/steel-sdk/) |
| 3 | +[>)](https://pypi.org/project/steel-sdk/) |
4 | 4 |
|
5 | 5 | The Steel Python library provides convenient access to the Steel REST API from any Python 3.8+ |
6 | 6 | application. The library includes type definitions for all request params and response fields, |
@@ -64,6 +64,39 @@ asyncio.run(main()) |
64 | 64 |
|
65 | 65 | Functionality between the synchronous and asynchronous clients is otherwise identical. |
66 | 66 |
|
| 67 | +### With aiohttp |
| 68 | + |
| 69 | +By default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend. |
| 70 | + |
| 71 | +You can enable this by installing `aiohttp`: |
| 72 | + |
| 73 | +```sh |
| 74 | +# install from PyPI |
| 75 | +pip install steel-sdk[aiohttp] |
| 76 | +``` |
| 77 | + |
| 78 | +Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`: |
| 79 | + |
| 80 | +```python |
| 81 | +import asyncio |
| 82 | +from steel import DefaultAioHttpClient |
| 83 | +from steel import AsyncSteel |
| 84 | + |
| 85 | + |
| 86 | +async def main() -> None: |
| 87 | + async with AsyncSteel( |
| 88 | + http_client=DefaultAioHttpClient(), |
| 89 | + ) as client: |
| 90 | + session = await client.sessions.create( |
| 91 | + api_timeout=20000, |
| 92 | + use_proxy=True, |
| 93 | + ) |
| 94 | + print(session.id) |
| 95 | + |
| 96 | + |
| 97 | +asyncio.run(main()) |
| 98 | +``` |
| 99 | + |
67 | 100 | ## Using types |
68 | 101 |
|
69 | 102 | 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: |
@@ -224,7 +257,7 @@ client.with_options(max_retries=5).sessions.create() |
224 | 257 | ### Timeouts |
225 | 258 |
|
226 | 259 | By default requests time out after 1 minute. You can configure this with a `timeout` option, |
227 | | -which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object: |
| 260 | +which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object: |
228 | 261 |
|
229 | 262 | ```python |
230 | 263 | from steel import Steel |
|
0 commit comments