python-wb 0.1.0__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.
- python_wb-0.1.0/LICENSE +21 -0
- python_wb-0.1.0/PKG-INFO +185 -0
- python_wb-0.1.0/README.md +165 -0
- python_wb-0.1.0/pyproject.toml +29 -0
- python_wb-0.1.0/setup.cfg +4 -0
- python_wb-0.1.0/src/python_wb.egg-info/PKG-INFO +185 -0
- python_wb-0.1.0/src/python_wb.egg-info/SOURCES.txt +28 -0
- python_wb-0.1.0/src/python_wb.egg-info/dependency_links.txt +1 -0
- python_wb-0.1.0/src/python_wb.egg-info/requires.txt +5 -0
- python_wb-0.1.0/src/python_wb.egg-info/top_level.txt +2 -0
- python_wb-0.1.0/src/pywb/__init__.py +12 -0
- python_wb-0.1.0/src/pywb/__meta__.py +1 -0
- python_wb-0.1.0/src/pywb/client/__init__.py +0 -0
- python_wb-0.1.0/src/pywb/client/session/__init__.py +0 -0
- python_wb-0.1.0/src/pywb/client/session/aiohttp.py +131 -0
- python_wb-0.1.0/src/pywb/client/session/base.py +185 -0
- python_wb-0.1.0/src/pywb/client/wb_client.py +122 -0
- python_wb-0.1.0/src/pywb/enums/__init__.py +7 -0
- python_wb-0.1.0/src/pywb/enums/urls.py +39 -0
- python_wb-0.1.0/src/pywb/exceptions.py +83 -0
- python_wb-0.1.0/src/pywb/methods/__init__.py +12 -0
- python_wb-0.1.0/src/pywb/methods/base.py +16 -0
- python_wb-0.1.0/src/pywb/methods/ping.py +24 -0
- python_wb-0.1.0/src/pywb/methods/statistics.py +19 -0
- python_wb-0.1.0/src/pywb/methods/update_product_card.py +16 -0
- python_wb-0.1.0/src/pywb/types/__init__.py +7 -0
- python_wb-0.1.0/src/pywb/types/order.py +34 -0
- python_wb-0.1.0/src/pywb/types/ping_response.py +6 -0
- python_wb-0.1.0/src/pywb/utils/errors.py +46 -0
- python_wb-0.1.0/src/test.py +18 -0
python_wb-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Browser Use Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
python_wb-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-wb
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Библиотека для работы с API Wildberries на Python.
|
|
5
|
+
Author-email: MistakeTZ <mistaketz@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/mistaketz/pywb
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/mistaketz/pywb/issues
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.12
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: aiohttp>=3.13.5
|
|
15
|
+
Requires-Dist: build>=1.4.2
|
|
16
|
+
Requires-Dist: httpx>=0.28.1
|
|
17
|
+
Requires-Dist: pydantic>=2.12.5
|
|
18
|
+
Requires-Dist: setuptools>=82.0.1
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
## pywb
|
|
22
|
+
|
|
23
|
+
Asynchronous Python client for working with the Wildberries Seller API.
|
|
24
|
+
|
|
25
|
+
The library provides:
|
|
26
|
+
|
|
27
|
+
- async HTTP client based on `aiohttp`
|
|
28
|
+
- typed request/response models via `pydantic`
|
|
29
|
+
- centralized API error mapping to Python exceptions
|
|
30
|
+
- support for multiple Wildberries API domains
|
|
31
|
+
|
|
32
|
+
## Features
|
|
33
|
+
|
|
34
|
+
- Easy entry point through `WBClient`
|
|
35
|
+
- Domain routing (`common`, `content`, `statistics`, etc.)
|
|
36
|
+
- Built-in methods:
|
|
37
|
+
- ping (`client.ping()`)
|
|
38
|
+
- content ping (`client.ping_content()`)
|
|
39
|
+
- statistics orders report (`client.get_orders(...)`)
|
|
40
|
+
- etc.
|
|
41
|
+
- Generic low-level method execution:
|
|
42
|
+
- `await client(SomeWBMethod(...))`
|
|
43
|
+
- Context manager support:
|
|
44
|
+
- `async with WBClient(...) as client:`
|
|
45
|
+
|
|
46
|
+
## Requirements
|
|
47
|
+
|
|
48
|
+
- Python 3.12+
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
Using `uv`:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
uv add python-wb
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
With `pip`:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install python-wb
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Quick Start
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
import asyncio
|
|
68
|
+
from pywb import WBClient
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
async def main() -> None:
|
|
72
|
+
token = "YOUR_WB_API_TOKEN"
|
|
73
|
+
|
|
74
|
+
async with WBClient(token) as client:
|
|
75
|
+
result = await client.ping()
|
|
76
|
+
print(result.ts, result.status)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
if __name__ == "__main__":
|
|
80
|
+
asyncio.run(main())
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Usage
|
|
84
|
+
|
|
85
|
+
### 1) Health check
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
result = await client.ping()
|
|
89
|
+
print(result.status)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 2) Content API health check
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
result = await client.ping_content()
|
|
96
|
+
print(result.status)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### 3) Get orders from Statistics API
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from datetime import datetime
|
|
103
|
+
|
|
104
|
+
orders = await client.get_orders(
|
|
105
|
+
date_from=datetime(2026, 1, 1, 0, 0, 0),
|
|
106
|
+
flag=0,
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
if orders:
|
|
110
|
+
print(orders[0].srid, orders[0].brand)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
`date_from` accepts either:
|
|
114
|
+
|
|
115
|
+
- ISO 8601 string (example: `"2022-03-04T18:08:31"`)
|
|
116
|
+
- `datetime` object
|
|
117
|
+
|
|
118
|
+
## Low-Level Method Call
|
|
119
|
+
|
|
120
|
+
You can call method objects directly through the client:
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from pywb.methods import Ping
|
|
124
|
+
|
|
125
|
+
response = await client(Ping())
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
This is useful when adding new method classes while keeping one transport layer.
|
|
129
|
+
|
|
130
|
+
## Error Handling
|
|
131
|
+
|
|
132
|
+
HTTP errors are mapped to dedicated exceptions:
|
|
133
|
+
|
|
134
|
+
- `BadRequestError` (400)
|
|
135
|
+
- `UnauthorizedError` (401)
|
|
136
|
+
- `PaymentRequiredError` (402)
|
|
137
|
+
- `AccessDeniedError` (403)
|
|
138
|
+
- `NotFoundError` (404)
|
|
139
|
+
- `ConflictError` (409)
|
|
140
|
+
- `PayloadTooLargeError` (413)
|
|
141
|
+
- `UnprocessableEntityError` (422)
|
|
142
|
+
- `TooManyRequestsError` (429)
|
|
143
|
+
- `InternalServerError` (5xx)
|
|
144
|
+
|
|
145
|
+
Base type: `WBApiError`
|
|
146
|
+
|
|
147
|
+
Example:
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
from pywb.exceptions import BadRequestError
|
|
151
|
+
|
|
152
|
+
try:
|
|
153
|
+
await client.get_orders(date_from="2022-03-04T18:08:31")
|
|
154
|
+
except BadRequestError as e:
|
|
155
|
+
print(e)
|
|
156
|
+
print(e.payload)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Network/transport failures in the `aiohttp` session are raised as `WBNetworkError`.
|
|
160
|
+
|
|
161
|
+
## Sandbox and Domains
|
|
162
|
+
|
|
163
|
+
The client supports domain-based URL routing through `WBDomain` and `WB_ROUTER`.
|
|
164
|
+
|
|
165
|
+
To enable sandbox mode (only where available for a domain):
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
client = WBClient(token="YOUR_TOKEN", is_sandbox=True)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
If sandbox is unavailable for a domain, a `ValueError` is raised by the session router.
|
|
172
|
+
|
|
173
|
+
## Development
|
|
174
|
+
|
|
175
|
+
Run the example script:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
python examples/ping.py
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Notes
|
|
182
|
+
|
|
183
|
+
- Keep your API token secret and do not commit it to git.
|
|
184
|
+
- Respect Wildberries API rate limits for each endpoint.
|
|
185
|
+
- For the statistics orders endpoint, use pagination strategy based on the last record timestamp when handling large datasets.
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
## pywb
|
|
2
|
+
|
|
3
|
+
Asynchronous Python client for working with the Wildberries Seller API.
|
|
4
|
+
|
|
5
|
+
The library provides:
|
|
6
|
+
|
|
7
|
+
- async HTTP client based on `aiohttp`
|
|
8
|
+
- typed request/response models via `pydantic`
|
|
9
|
+
- centralized API error mapping to Python exceptions
|
|
10
|
+
- support for multiple Wildberries API domains
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- Easy entry point through `WBClient`
|
|
15
|
+
- Domain routing (`common`, `content`, `statistics`, etc.)
|
|
16
|
+
- Built-in methods:
|
|
17
|
+
- ping (`client.ping()`)
|
|
18
|
+
- content ping (`client.ping_content()`)
|
|
19
|
+
- statistics orders report (`client.get_orders(...)`)
|
|
20
|
+
- etc.
|
|
21
|
+
- Generic low-level method execution:
|
|
22
|
+
- `await client(SomeWBMethod(...))`
|
|
23
|
+
- Context manager support:
|
|
24
|
+
- `async with WBClient(...) as client:`
|
|
25
|
+
|
|
26
|
+
## Requirements
|
|
27
|
+
|
|
28
|
+
- Python 3.12+
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
Using `uv`:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
uv add python-wb
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
With `pip`:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install python-wb
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Quick Start
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
import asyncio
|
|
48
|
+
from pywb import WBClient
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
async def main() -> None:
|
|
52
|
+
token = "YOUR_WB_API_TOKEN"
|
|
53
|
+
|
|
54
|
+
async with WBClient(token) as client:
|
|
55
|
+
result = await client.ping()
|
|
56
|
+
print(result.ts, result.status)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
if __name__ == "__main__":
|
|
60
|
+
asyncio.run(main())
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Usage
|
|
64
|
+
|
|
65
|
+
### 1) Health check
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
result = await client.ping()
|
|
69
|
+
print(result.status)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 2) Content API health check
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
result = await client.ping_content()
|
|
76
|
+
print(result.status)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 3) Get orders from Statistics API
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from datetime import datetime
|
|
83
|
+
|
|
84
|
+
orders = await client.get_orders(
|
|
85
|
+
date_from=datetime(2026, 1, 1, 0, 0, 0),
|
|
86
|
+
flag=0,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
if orders:
|
|
90
|
+
print(orders[0].srid, orders[0].brand)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
`date_from` accepts either:
|
|
94
|
+
|
|
95
|
+
- ISO 8601 string (example: `"2022-03-04T18:08:31"`)
|
|
96
|
+
- `datetime` object
|
|
97
|
+
|
|
98
|
+
## Low-Level Method Call
|
|
99
|
+
|
|
100
|
+
You can call method objects directly through the client:
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from pywb.methods import Ping
|
|
104
|
+
|
|
105
|
+
response = await client(Ping())
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
This is useful when adding new method classes while keeping one transport layer.
|
|
109
|
+
|
|
110
|
+
## Error Handling
|
|
111
|
+
|
|
112
|
+
HTTP errors are mapped to dedicated exceptions:
|
|
113
|
+
|
|
114
|
+
- `BadRequestError` (400)
|
|
115
|
+
- `UnauthorizedError` (401)
|
|
116
|
+
- `PaymentRequiredError` (402)
|
|
117
|
+
- `AccessDeniedError` (403)
|
|
118
|
+
- `NotFoundError` (404)
|
|
119
|
+
- `ConflictError` (409)
|
|
120
|
+
- `PayloadTooLargeError` (413)
|
|
121
|
+
- `UnprocessableEntityError` (422)
|
|
122
|
+
- `TooManyRequestsError` (429)
|
|
123
|
+
- `InternalServerError` (5xx)
|
|
124
|
+
|
|
125
|
+
Base type: `WBApiError`
|
|
126
|
+
|
|
127
|
+
Example:
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from pywb.exceptions import BadRequestError
|
|
131
|
+
|
|
132
|
+
try:
|
|
133
|
+
await client.get_orders(date_from="2022-03-04T18:08:31")
|
|
134
|
+
except BadRequestError as e:
|
|
135
|
+
print(e)
|
|
136
|
+
print(e.payload)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Network/transport failures in the `aiohttp` session are raised as `WBNetworkError`.
|
|
140
|
+
|
|
141
|
+
## Sandbox and Domains
|
|
142
|
+
|
|
143
|
+
The client supports domain-based URL routing through `WBDomain` and `WB_ROUTER`.
|
|
144
|
+
|
|
145
|
+
To enable sandbox mode (only where available for a domain):
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
client = WBClient(token="YOUR_TOKEN", is_sandbox=True)
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
If sandbox is unavailable for a domain, a `ValueError` is raised by the session router.
|
|
152
|
+
|
|
153
|
+
## Development
|
|
154
|
+
|
|
155
|
+
Run the example script:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
python examples/ping.py
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Notes
|
|
162
|
+
|
|
163
|
+
- Keep your API token secret and do not commit it to git.
|
|
164
|
+
- Respect Wildberries API rate limits for each endpoint.
|
|
165
|
+
- For the statistics orders endpoint, use pagination strategy based on the last record timestamp when handling large datasets.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "python-wb"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name="MistakeTZ", email="mistaketz@gmail.com" },
|
|
10
|
+
]
|
|
11
|
+
description = "Библиотека для работы с API Wildberries на Python."
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.12"
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
]
|
|
19
|
+
dependencies = [
|
|
20
|
+
"aiohttp>=3.13.5",
|
|
21
|
+
"build>=1.4.2",
|
|
22
|
+
"httpx>=0.28.1",
|
|
23
|
+
"pydantic>=2.12.5",
|
|
24
|
+
"setuptools>=82.0.1",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
"Homepage" = "https://github.com/mistaketz/pywb"
|
|
29
|
+
"Bug Tracker" = "https://github.com/mistaketz/pywb/issues"
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-wb
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Библиотека для работы с API Wildberries на Python.
|
|
5
|
+
Author-email: MistakeTZ <mistaketz@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/mistaketz/pywb
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/mistaketz/pywb/issues
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.12
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: aiohttp>=3.13.5
|
|
15
|
+
Requires-Dist: build>=1.4.2
|
|
16
|
+
Requires-Dist: httpx>=0.28.1
|
|
17
|
+
Requires-Dist: pydantic>=2.12.5
|
|
18
|
+
Requires-Dist: setuptools>=82.0.1
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
## pywb
|
|
22
|
+
|
|
23
|
+
Asynchronous Python client for working with the Wildberries Seller API.
|
|
24
|
+
|
|
25
|
+
The library provides:
|
|
26
|
+
|
|
27
|
+
- async HTTP client based on `aiohttp`
|
|
28
|
+
- typed request/response models via `pydantic`
|
|
29
|
+
- centralized API error mapping to Python exceptions
|
|
30
|
+
- support for multiple Wildberries API domains
|
|
31
|
+
|
|
32
|
+
## Features
|
|
33
|
+
|
|
34
|
+
- Easy entry point through `WBClient`
|
|
35
|
+
- Domain routing (`common`, `content`, `statistics`, etc.)
|
|
36
|
+
- Built-in methods:
|
|
37
|
+
- ping (`client.ping()`)
|
|
38
|
+
- content ping (`client.ping_content()`)
|
|
39
|
+
- statistics orders report (`client.get_orders(...)`)
|
|
40
|
+
- etc.
|
|
41
|
+
- Generic low-level method execution:
|
|
42
|
+
- `await client(SomeWBMethod(...))`
|
|
43
|
+
- Context manager support:
|
|
44
|
+
- `async with WBClient(...) as client:`
|
|
45
|
+
|
|
46
|
+
## Requirements
|
|
47
|
+
|
|
48
|
+
- Python 3.12+
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
Using `uv`:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
uv add python-wb
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
With `pip`:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install python-wb
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Quick Start
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
import asyncio
|
|
68
|
+
from pywb import WBClient
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
async def main() -> None:
|
|
72
|
+
token = "YOUR_WB_API_TOKEN"
|
|
73
|
+
|
|
74
|
+
async with WBClient(token) as client:
|
|
75
|
+
result = await client.ping()
|
|
76
|
+
print(result.ts, result.status)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
if __name__ == "__main__":
|
|
80
|
+
asyncio.run(main())
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Usage
|
|
84
|
+
|
|
85
|
+
### 1) Health check
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
result = await client.ping()
|
|
89
|
+
print(result.status)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 2) Content API health check
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
result = await client.ping_content()
|
|
96
|
+
print(result.status)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### 3) Get orders from Statistics API
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from datetime import datetime
|
|
103
|
+
|
|
104
|
+
orders = await client.get_orders(
|
|
105
|
+
date_from=datetime(2026, 1, 1, 0, 0, 0),
|
|
106
|
+
flag=0,
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
if orders:
|
|
110
|
+
print(orders[0].srid, orders[0].brand)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
`date_from` accepts either:
|
|
114
|
+
|
|
115
|
+
- ISO 8601 string (example: `"2022-03-04T18:08:31"`)
|
|
116
|
+
- `datetime` object
|
|
117
|
+
|
|
118
|
+
## Low-Level Method Call
|
|
119
|
+
|
|
120
|
+
You can call method objects directly through the client:
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from pywb.methods import Ping
|
|
124
|
+
|
|
125
|
+
response = await client(Ping())
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
This is useful when adding new method classes while keeping one transport layer.
|
|
129
|
+
|
|
130
|
+
## Error Handling
|
|
131
|
+
|
|
132
|
+
HTTP errors are mapped to dedicated exceptions:
|
|
133
|
+
|
|
134
|
+
- `BadRequestError` (400)
|
|
135
|
+
- `UnauthorizedError` (401)
|
|
136
|
+
- `PaymentRequiredError` (402)
|
|
137
|
+
- `AccessDeniedError` (403)
|
|
138
|
+
- `NotFoundError` (404)
|
|
139
|
+
- `ConflictError` (409)
|
|
140
|
+
- `PayloadTooLargeError` (413)
|
|
141
|
+
- `UnprocessableEntityError` (422)
|
|
142
|
+
- `TooManyRequestsError` (429)
|
|
143
|
+
- `InternalServerError` (5xx)
|
|
144
|
+
|
|
145
|
+
Base type: `WBApiError`
|
|
146
|
+
|
|
147
|
+
Example:
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
from pywb.exceptions import BadRequestError
|
|
151
|
+
|
|
152
|
+
try:
|
|
153
|
+
await client.get_orders(date_from="2022-03-04T18:08:31")
|
|
154
|
+
except BadRequestError as e:
|
|
155
|
+
print(e)
|
|
156
|
+
print(e.payload)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Network/transport failures in the `aiohttp` session are raised as `WBNetworkError`.
|
|
160
|
+
|
|
161
|
+
## Sandbox and Domains
|
|
162
|
+
|
|
163
|
+
The client supports domain-based URL routing through `WBDomain` and `WB_ROUTER`.
|
|
164
|
+
|
|
165
|
+
To enable sandbox mode (only where available for a domain):
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
client = WBClient(token="YOUR_TOKEN", is_sandbox=True)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
If sandbox is unavailable for a domain, a `ValueError` is raised by the session router.
|
|
172
|
+
|
|
173
|
+
## Development
|
|
174
|
+
|
|
175
|
+
Run the example script:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
python examples/ping.py
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Notes
|
|
182
|
+
|
|
183
|
+
- Keep your API token secret and do not commit it to git.
|
|
184
|
+
- Respect Wildberries API rate limits for each endpoint.
|
|
185
|
+
- For the statistics orders endpoint, use pagination strategy based on the last record timestamp when handling large datasets.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/test.py
|
|
5
|
+
src/python_wb.egg-info/PKG-INFO
|
|
6
|
+
src/python_wb.egg-info/SOURCES.txt
|
|
7
|
+
src/python_wb.egg-info/dependency_links.txt
|
|
8
|
+
src/python_wb.egg-info/requires.txt
|
|
9
|
+
src/python_wb.egg-info/top_level.txt
|
|
10
|
+
src/pywb/__init__.py
|
|
11
|
+
src/pywb/__meta__.py
|
|
12
|
+
src/pywb/exceptions.py
|
|
13
|
+
src/pywb/client/__init__.py
|
|
14
|
+
src/pywb/client/wb_client.py
|
|
15
|
+
src/pywb/client/session/__init__.py
|
|
16
|
+
src/pywb/client/session/aiohttp.py
|
|
17
|
+
src/pywb/client/session/base.py
|
|
18
|
+
src/pywb/enums/__init__.py
|
|
19
|
+
src/pywb/enums/urls.py
|
|
20
|
+
src/pywb/methods/__init__.py
|
|
21
|
+
src/pywb/methods/base.py
|
|
22
|
+
src/pywb/methods/ping.py
|
|
23
|
+
src/pywb/methods/statistics.py
|
|
24
|
+
src/pywb/methods/update_product_card.py
|
|
25
|
+
src/pywb/types/__init__.py
|
|
26
|
+
src/pywb/types/order.py
|
|
27
|
+
src/pywb/types/ping_response.py
|
|
28
|
+
src/pywb/utils/errors.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.1"
|
|
File without changes
|
|
File without changes
|