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
***client:** don't send Content-Type header on GET requests ([41feabc](https://github.com/DataMini/asktable-python/commit/41feabcb23fb5c257d18ba7f96f0ddb9304d53d5))
22
+
***docs/api:** remove references to nonexistent types ([7d673d4](https://github.com/DataMini/asktable-python/commit/7d673d44b295a507ca08ff0982cc5e033893e3d3))
23
+
***pagination:** correct next page check ([03552e7](https://github.com/DataMini/asktable-python/commit/03552e74ca1fa48289b48381777b1243398777bc))
***tests:** fix: tests which call HTTP endpoints directly with the example parameters ([3036c4b](https://github.com/DataMini/asktable-python/commit/3036c4bdbe59cd13bdfacdd113478e3e6ddd8ca0))
26
+
27
+
28
+
### Chores
29
+
30
+
***ci:** change upload type ([267f707](https://github.com/DataMini/asktable-python/commit/267f707806319c9b4499046f286f891a985d22de))
31
+
***ci:** enable for pull requests ([a6636e7](https://github.com/DataMini/asktable-python/commit/a6636e7b8409f7750b52c4850f05be437e4ed31d))
32
+
***ci:** only run for pushes and fork pull requests ([f5756ca](https://github.com/DataMini/asktable-python/commit/f5756ca55464cba7219498f0fcf0786d299fdc7d))
33
+
***docs:** remove reference to rye shell ([9fc4749](https://github.com/DataMini/asktable-python/commit/9fc4749e8965d398f281078e14f0249d12571ace))
***tests:** add tests for httpx client instantiation & proxies ([c620e09](https://github.com/DataMini/asktable-python/commit/c620e09f4be03fabc31167839018e69b8d7f5d7b))
43
+
***tests:** run tests in parallel ([9d9d65e](https://github.com/DataMini/asktable-python/commit/9d9d65e5be80faba732cd2d29854186ff565b4c7))
44
+
***tests:** skip some failing tests on the latest python versions ([188abef](https://github.com/DataMini/asktable-python/commit/188abef74adcaf1c5b8b4ee8b39315aba98c7f95))
The Asktable Python library provides convenient access to the Asktable REST API from any Python 3.8+
6
7
application. The library includes type definitions for all request params and response fields,
@@ -24,9 +25,12 @@ pip install asktable
24
25
The full API of this library can be found in [api.md](api.md).
25
26
26
27
```python
28
+
import os
27
29
from asktable import Asktable
28
30
29
-
client = Asktable()
31
+
client = Asktable(
32
+
api_key=os.environ.get("ASKTABLE_API_KEY"), # This is the default and can be omitted
33
+
)
30
34
31
35
datasource = client.datasources.create(
32
36
engine="mysql",
@@ -44,10 +48,13 @@ so that your API Key is not stored in source control.
44
48
Simply import `AsyncAsktable` instead of `Asktable` and use `await` with each API call:
45
49
46
50
```python
51
+
import os
47
52
import asyncio
48
53
from asktable import AsyncAsktable
49
54
50
-
client = AsyncAsktable()
55
+
client = AsyncAsktable(
56
+
api_key=os.environ.get("ASKTABLE_API_KEY"), # This is the default and can be omitted
57
+
)
51
58
52
59
53
60
asyncdefmain() -> None:
@@ -62,6 +69,39 @@ asyncio.run(main())
62
69
63
70
Functionality between the synchronous and asynchronous clients is otherwise identical.
64
71
72
+
### With aiohttp
73
+
74
+
By default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.
75
+
76
+
You can enable this by installing `aiohttp`:
77
+
78
+
```sh
79
+
# install from PyPI
80
+
pip install asktable[aiohttp]
81
+
```
82
+
83
+
Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:
84
+
85
+
```python
86
+
import asyncio
87
+
from asktable import DefaultAioHttpClient
88
+
from asktable import AsyncAsktable
89
+
90
+
91
+
asyncdefmain() -> None:
92
+
asyncwith AsyncAsktable(
93
+
api_key="My API Key",
94
+
http_client=DefaultAioHttpClient(),
95
+
) as client:
96
+
datasource =await client.datasources.create(
97
+
engine="mysql",
98
+
)
99
+
print(datasource.id)
100
+
101
+
102
+
asyncio.run(main())
103
+
```
104
+
65
105
## Using types
66
106
67
107
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:
0 commit comments