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.1.tar.gz (56.8 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.1-py3-none-any.whl (74.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_wb-0.2.1.tar.gz
  • Upload date:
  • Size: 56.8 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.1.tar.gz
Algorithm Hash digest
SHA256 42010261ca649292af6edecc4c68947bf6454ede6024b44679bab7512f05b51d
MD5 544f7e07b100c62b257471de4dea2909
BLAKE2b-256 39d1fdfcd290ef0dc6ab0fa1207104393dcdde129ca7753b31290411f978374d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_wb-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 74.0 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 388be51f23a783e54c0757f66db785142b0e611e7c2bf065bf0b447d0d032382
MD5 a477596d98c80c7d6e12d12faf1f27ed
BLAKE2b-256 b700579731b68064143268e1a832774168711814dd69ad0e17302f9c732e5b25

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