|
1 | 1 | # Arcade Python API library
|
2 | 2 |
|
3 |
| -[>)](https://pypi.org/project/arcadepy/) |
| 3 | +<!-- prettier-ignore --> |
| 4 | +[)](https://pypi.org/project/arcadepy/) |
4 | 5 |
|
5 | 6 | The Arcade Python library provides convenient access to the Arcade REST API from any Python 3.8+
|
6 | 7 | application. The library includes type definitions for all request params and response fields,
|
@@ -72,6 +73,41 @@ asyncio.run(main())
|
72 | 73 |
|
73 | 74 | Functionality between the synchronous and asynchronous clients is otherwise identical.
|
74 | 75 |
|
| 76 | +### With aiohttp |
| 77 | + |
| 78 | +By default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend. |
| 79 | + |
| 80 | +You can enable this by installing `aiohttp`: |
| 81 | + |
| 82 | +```sh |
| 83 | +# install from PyPI |
| 84 | +pip install arcadepy[aiohttp] |
| 85 | +``` |
| 86 | + |
| 87 | +Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`: |
| 88 | + |
| 89 | +```python |
| 90 | +import asyncio |
| 91 | +from arcadepy import DefaultAioHttpClient |
| 92 | +from arcadepy import AsyncArcade |
| 93 | + |
| 94 | + |
| 95 | +async def main() -> None: |
| 96 | + async with AsyncArcade( |
| 97 | + api_key="My API Key", |
| 98 | + http_client=DefaultAioHttpClient(), |
| 99 | + ) as client: |
| 100 | + execute_tool_response = await client.tools.execute( |
| 101 | + tool_name="Google.ListEmails", |
| 102 | + input={"n_emails": 10}, |
| 103 | + |
| 104 | + ) |
| 105 | + print(execute_tool_response.id) |
| 106 | + |
| 107 | + |
| 108 | +asyncio.run(main()) |
| 109 | +``` |
| 110 | + |
75 | 111 | ## Using types
|
76 | 112 |
|
77 | 113 | 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:
|
@@ -175,7 +211,7 @@ client.with_options(max_retries=5).chat.completions.create(
|
175 | 211 | ### Timeouts
|
176 | 212 |
|
177 | 213 | By default requests time out after 1 minute. You can configure this with a `timeout` option,
|
178 |
| -which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object: |
| 214 | +which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object: |
179 | 215 |
|
180 | 216 | ```python
|
181 | 217 | from arcadepy import Arcade
|
|
0 commit comments