Skip to main content

Библиотека для работы с API Wildberries на Python.

Project description

pywb

Asynchronous Python client for working with the Wildberries Seller API.

The library provides:

  • async HTTP client based on aiohttp
  • typed request/response models via pydantic
  • centralized API error mapping to Python exceptions
  • support for multiple Wildberries API domains

Features

  • Easy entry point through WBClient
  • Domain routing (common, content, statistics, etc.)
  • Built-in methods:
    • ping (client.ping())
    • content ping (client.ping_content())
    • statistics orders report (client.get_orders(...))
    • etc.
  • Generic low-level method execution:
    • await client(SomeWBMethod(...))
  • Context manager support:
    • async with WBClient(...) as client:

Requirements

  • Python 3.12+

Installation

Using uv:

uv add python-wb

With pip:

pip install python-wb

Quick Start

import asyncio
from pywb import WBClient


async def main() -> None:
    token = "YOUR_WB_API_TOKEN"

    async with WBClient(token) as client:
        result = await client.ping()
        print(result.ts, result.status)


if __name__ == "__main__":
    asyncio.run(main())

Usage

1) Health check

result = await client.ping()
print(result.status)

2) Content API health check

result = await client.ping_content()
print(result.status)

3) Get orders from Statistics API

from datetime import datetime

orders = await client.get_orders(
    date_from=datetime(2026, 1, 1, 0, 0, 0),
    flag=0,
)

if orders:
    print(orders[0].srid, orders[0].brand)

date_from accepts either:

  • ISO 8601 string (example: "2022-03-04T18:08:31")
  • datetime object

Low-Level Method Call

You can call method objects directly through the client:

from pywb.methods import Ping

response = await client(Ping())

This is useful when adding new method classes while keeping one transport layer.

Error Handling

HTTP errors are mapped to dedicated exceptions:

  • BadRequestError (400)
  • UnauthorizedError (401)
  • PaymentRequiredError (402)
  • AccessDeniedError (403)
  • NotFoundError (404)
  • ConflictError (409)
  • PayloadTooLargeError (413)
  • UnprocessableEntityError (422)
  • TooManyRequestsError (429)
  • InternalServerError (5xx)

Base type: WBApiError

Example:

from pywb.exceptions import BadRequestError

try:
    await client.get_orders(date_from="2022-03-04T18:08:31")
except BadRequestError as e:
    print(e)
    print(e.payload)

Network/transport failures in the aiohttp session are raised as WBNetworkError.

Sandbox and Domains

The client supports domain-based URL routing through WBDomain and WB_ROUTER.

To enable sandbox mode (only where available for a domain):

client = WBClient(token="YOUR_TOKEN", is_sandbox=True)

If sandbox is unavailable for a domain, a ValueError is raised by the session router.

Notes

  • Keep your API token secret and do not commit it to git.
  • Respect Wildberries API rate limits for each endpoint.
  • For the statistics orders endpoint, use pagination strategy based on the last record timestamp when handling large datasets.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_wb-0.2.2.tar.gz (57.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_wb-0.2.2-py3-none-any.whl (74.2 kB view details)

Uploaded Python 3

File details

Details for the file python_wb-0.2.2.tar.gz.

File metadata

  • Download URL: python_wb-0.2.2.tar.gz
  • Upload date:
  • Size: 57.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for python_wb-0.2.2.tar.gz
Algorithm Hash digest
SHA256 d40deff5a6087e6bd120e101e962b0b000a781073c13549fad292f6d9a3e0895
MD5 6a0a712579dcd874ba9555b994f70bd9
BLAKE2b-256 6ed4865113a15e95a6ccd4d09f4a6894c525ba3c1f6d859acf4ec0cdcfc3a0b1

See more details on using hashes here.

File details

Details for the file python_wb-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: python_wb-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 74.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for python_wb-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1326a564a3564ccc1fd07affe2fc3ba97d62eb1da22d9bb0c1891c78e1b3d7c9
MD5 b567af2d9ea6c6f60da1ea44891b6789
BLAKE2b-256 ad2e65415447390f96f086327174a053242b93831b5b21df42ee0bcf545f664d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page