uapi-sdk-python 0.1.13__tar.gz → 0.1.15__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {uapi_sdk_python-0.1.13 → uapi_sdk_python-0.1.15}/PKG-INFO +8 -23
- {uapi_sdk_python-0.1.13 → uapi_sdk_python-0.1.15}/README.md +7 -22
- {uapi_sdk_python-0.1.13 → uapi_sdk_python-0.1.15}/pyproject.toml +1 -1
- {uapi_sdk_python-0.1.13 → uapi_sdk_python-0.1.15}/uapi/client.py +1089 -90
- {uapi_sdk_python-0.1.13 → uapi_sdk_python-0.1.15}/uapi_sdk_python.egg-info/PKG-INFO +8 -23
- {uapi_sdk_python-0.1.13 → uapi_sdk_python-0.1.15}/setup.cfg +0 -0
- {uapi_sdk_python-0.1.13 → uapi_sdk_python-0.1.15}/tests/test_client.py +0 -0
- {uapi_sdk_python-0.1.13 → uapi_sdk_python-0.1.15}/uapi/__init__.py +0 -0
- {uapi_sdk_python-0.1.13 → uapi_sdk_python-0.1.15}/uapi/errors.py +0 -0
- {uapi_sdk_python-0.1.13 → uapi_sdk_python-0.1.15}/uapi_sdk_python.egg-info/SOURCES.txt +0 -0
- {uapi_sdk_python-0.1.13 → uapi_sdk_python-0.1.15}/uapi_sdk_python.egg-info/dependency_links.txt +0 -0
- {uapi_sdk_python-0.1.13 → uapi_sdk_python-0.1.15}/uapi_sdk_python.egg-info/requires.txt +0 -0
- {uapi_sdk_python-0.1.13 → uapi_sdk_python-0.1.15}/uapi_sdk_python.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: uapi-sdk-python
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.15
|
|
4
4
|
Summary: Idiomatic UAPI SDK for Python
|
|
5
5
|
Author-email: UAPI <dev@uapis.cn>
|
|
6
6
|
Requires-Python: >=3.9
|
|
@@ -32,7 +32,7 @@ pip install uapi-sdk-python
|
|
|
32
32
|
```python
|
|
33
33
|
from uapi import UapiClient
|
|
34
34
|
|
|
35
|
-
client = UapiClient("https://uapis.cn
|
|
35
|
+
client = UapiClient("https://uapis.cn", "YOUR_API_KEY")
|
|
36
36
|
result = client.social.get_social_qq_userinfo(qq="10001")
|
|
37
37
|
print(result)
|
|
38
38
|
```
|
|
@@ -62,7 +62,7 @@ print(result)
|
|
|
62
62
|
from functools import lru_cache
|
|
63
63
|
from uapi import UapiClient
|
|
64
64
|
|
|
65
|
-
client = UapiClient("https://uapis.cn
|
|
65
|
+
client = UapiClient("https://uapis.cn", token="YOUR_API_KEY")
|
|
66
66
|
|
|
67
67
|
@lru_cache(maxsize=128)
|
|
68
68
|
def cached_lookup(qq: str):
|
|
@@ -73,34 +73,19 @@ user = cached_lookup("10001")
|
|
|
73
73
|
|
|
74
74
|
也可以在 FastAPI / Django 项目里配合 Redis,将 SDK 的响应序列化后写入缓存,命中即直接返回。
|
|
75
75
|
|
|
76
|
-
###
|
|
76
|
+
### 调整超时与环境
|
|
77
77
|
|
|
78
78
|
```python
|
|
79
|
-
import httpx
|
|
80
|
-
from httpx import Auth
|
|
81
79
|
from uapi import UapiClient
|
|
82
80
|
|
|
83
|
-
class StaticToken(Auth):
|
|
84
|
-
def __init__(self, token: str):
|
|
85
|
-
self.token = token
|
|
86
|
-
def auth_flow(self, request):
|
|
87
|
-
request.headers["Authorization"] = f"Bearer {self.token}"
|
|
88
|
-
yield request
|
|
89
|
-
|
|
90
|
-
http_client = httpx.Client(
|
|
91
|
-
timeout=5,
|
|
92
|
-
transport=httpx.HTTPTransport(retries=3),
|
|
93
|
-
event_hooks={"request": [lambda request: print("->", request.url)]},
|
|
94
|
-
)
|
|
95
|
-
|
|
96
81
|
client = UapiClient(
|
|
97
|
-
"https://uapis.cn
|
|
98
|
-
|
|
99
|
-
|
|
82
|
+
"https://uapis.cn",
|
|
83
|
+
token="YOUR_API_KEY",
|
|
84
|
+
timeout=5.0,
|
|
100
85
|
)
|
|
101
86
|
```
|
|
102
87
|
|
|
103
|
-
|
|
88
|
+
如果你需要切换到别的环境,直接改 `base_url` 就可以;如果你只想缩短等待时间,传 `timeout` 就够了。
|
|
104
89
|
|
|
105
90
|
## 错误模型概览
|
|
106
91
|
|
|
@@ -18,7 +18,7 @@ pip install uapi-sdk-python
|
|
|
18
18
|
```python
|
|
19
19
|
from uapi import UapiClient
|
|
20
20
|
|
|
21
|
-
client = UapiClient("https://uapis.cn
|
|
21
|
+
client = UapiClient("https://uapis.cn", "YOUR_API_KEY")
|
|
22
22
|
result = client.social.get_social_qq_userinfo(qq="10001")
|
|
23
23
|
print(result)
|
|
24
24
|
```
|
|
@@ -48,7 +48,7 @@ print(result)
|
|
|
48
48
|
from functools import lru_cache
|
|
49
49
|
from uapi import UapiClient
|
|
50
50
|
|
|
51
|
-
client = UapiClient("https://uapis.cn
|
|
51
|
+
client = UapiClient("https://uapis.cn", token="YOUR_API_KEY")
|
|
52
52
|
|
|
53
53
|
@lru_cache(maxsize=128)
|
|
54
54
|
def cached_lookup(qq: str):
|
|
@@ -59,34 +59,19 @@ user = cached_lookup("10001")
|
|
|
59
59
|
|
|
60
60
|
也可以在 FastAPI / Django 项目里配合 Redis,将 SDK 的响应序列化后写入缓存,命中即直接返回。
|
|
61
61
|
|
|
62
|
-
###
|
|
62
|
+
### 调整超时与环境
|
|
63
63
|
|
|
64
64
|
```python
|
|
65
|
-
import httpx
|
|
66
|
-
from httpx import Auth
|
|
67
65
|
from uapi import UapiClient
|
|
68
66
|
|
|
69
|
-
class StaticToken(Auth):
|
|
70
|
-
def __init__(self, token: str):
|
|
71
|
-
self.token = token
|
|
72
|
-
def auth_flow(self, request):
|
|
73
|
-
request.headers["Authorization"] = f"Bearer {self.token}"
|
|
74
|
-
yield request
|
|
75
|
-
|
|
76
|
-
http_client = httpx.Client(
|
|
77
|
-
timeout=5,
|
|
78
|
-
transport=httpx.HTTPTransport(retries=3),
|
|
79
|
-
event_hooks={"request": [lambda request: print("->", request.url)]},
|
|
80
|
-
)
|
|
81
|
-
|
|
82
67
|
client = UapiClient(
|
|
83
|
-
"https://uapis.cn
|
|
84
|
-
|
|
85
|
-
|
|
68
|
+
"https://uapis.cn",
|
|
69
|
+
token="YOUR_API_KEY",
|
|
70
|
+
timeout=5.0,
|
|
86
71
|
)
|
|
87
72
|
```
|
|
88
73
|
|
|
89
|
-
|
|
74
|
+
如果你需要切换到别的环境,直接改 `base_url` 就可以;如果你只想缩短等待时间,传 `timeout` 就够了。
|
|
90
75
|
|
|
91
76
|
## 错误模型概览
|
|
92
77
|
|