Skip to main content
wbapi

Асинхронный клиент WB API

PyPI version Downloads Tests Coverage Checked with mypy msgspec Ruff Python

308 сгенерированных методов с автоматической пагинацией и понятными именами:

OpenAPI Generator wbapi
api_v3_supplies_post() api.orders_fbs.create_supply()
api_v3_orders_new_get() api.orders_fbs.get_orders_new()
api_v3_orders_order_id_cancel_patch() api.orders_fbs.cancel_order()
content_v2_get_cards_list_post() api.items.get_cards_list()

Установка

Требуется Python 3.10+.

pip install wbapi-async

Примеры использования

Новые сборочные задания

import asyncio
import os

from wbapi import WBApi


async def main():
    async with WBApi(token="your_token_here") as api:
        response = await api.orders_fbs.get_orders_new()
        for order in response.orders:
            print(f"{order.id}: артикул {order.nm_id}, {order.sale_price / 100:.2f} ₽")


asyncio.run(main())

End-to-end поставка FBS

import asyncio
import os

from wbapi import WBApi


async def main():
    async with WBApi(token="your_token_here") as api:
        supply = await api.orders_fbs.create_supply()
        print(f"Создана поставка: {supply.id}")

        new_orders = await api.orders_fbs.get_orders_new()
        order_ids = [order.id for order in new_orders.orders[:10]]
        await api.orders_fbs.update_supplies_order(supply_id=supply.id, orders=order_ids)
        print(f"Добавлено {len(order_ids)} новых сборочных заданий")

        await api.orders_fbs.update_supplies_deliver(supply_id=supply.id)
        print(f"Передана {supply.id} в доставку")


asyncio.run(main())

Пагинация

Клиент поддерживает все существующие схемы пагинации: токен, курсор, rrdId, смещение и подбирает нужную автоматически.

auto_paginate=True собирает все страницы в один список:

import asyncio

from wbapi import WBApi


async def main():
    async with WBApi(token="your_token_here") as api:
        rows = await api.orders_fbs.get_orders(limit=1000, next_=0, auto_paginate=True)
        print(f"Всего заказов: {len(rows)}")


asyncio.run(main())

На больших выборках лучше iter_* методы:

import asyncio

from wbapi import WBApi


async def main():
    async with WBApi(token="your_token_here") as api:
        async for order in api.orders_fbs.iter_get_orders(limit=1000, next_=0):
            print(order.id, order.nm_id)


asyncio.run(main())

Повторы и лимиты

429, 5xx и сетевые сбои повторяются автоматически — с экспоненциальной задержкой, джиттером и учётом заголовка X-Ratelimit-Retry. Лимиты wb соблюдаются по каждому эндпоинту отдельно.

Обработка ошибок

import asyncio
import os

from wbapi import WBApi
from wbapi.exceptions import WBAPIError, WBAuthError, WBRateLimitError


async def main():
    async with WBApi(token="your_token_here") as api:
        try:
            await api.orders_fbs.get_orders_new()
        except WBAuthError:
            print("Токен просрочен или у него нет доступа к нужной категории")
        except WBRateLimitError as error:
            print(f"Превышен лимит, повтор через {error.retry_after} с")
        except WBAPIError as error:
            print(f"WB вернул {error.status_code}: {error}")


asyncio.run(main())

Песочница

Вы можете протестировать методы API на случайных данных. Для этого понадобится токен с опцией Тестовый контур.

Данные в тестовом контуре сгенерированы случайным образом и не принадлежат реальным продавцам. Использование тестового контура не несёт риска непреднамеренного раскрытия информации.

async with WBApi(token="your_token_here", sandbox=True) as api:
    supply = await api.orders_fbs.create_supply(name="test")

Лицензия

MIT

Download files

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

Source Distribution

wbapi_async-1.0.1.tar.gz (136.5 kB view details)

Uploaded Source

Built Distribution

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

wbapi_async-1.0.1-py3-none-any.whl (178.9 kB view details)

Uploaded Python 3

File details

Details for the file wbapi_async-1.0.1.tar.gz.

File metadata

  • Download URL: wbapi_async-1.0.1.tar.gz
  • Upload date:
  • Size: 136.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for wbapi_async-1.0.1.tar.gz
Algorithm Hash digest
SHA256 54cf45f993d0e96d1900042a39d0ac9b7b31932f1baef0f6a5ada17696cd026a
MD5 71e916e5c4c4a37594ddf38b7c8e0787
BLAKE2b-256 76b82850a85be29f69e80c9240727647a73e1eb7945075cc89c48fe770002b64

See more details on using hashes here.

Provenance

The following attestation bundles were made for wbapi_async-1.0.1.tar.gz:

Publisher: pypi_release.yml on serdukow/wbapi-async

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wbapi_async-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: wbapi_async-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 178.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for wbapi_async-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9af872774eacc612f2701d4afede7418fa5a07e876c8121f391bdad7e9dc37e2
MD5 8dd14f92d141faf2dc5bc932eef34286
BLAKE2b-256 e189b6c4da66a87173610e944fd811bcb5c2ec0c3d662a1b9dddd755988a11e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for wbapi_async-1.0.1-py3-none-any.whl:

Publisher: pypi_release.yml on serdukow/wbapi-async

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.1.1

2 files

1.1.0

2 files

1.0.3

2 files

1.0.2

2 files

This release

1.0.1 This release

2 files

1.0.0

2 files

0.10.1

2 files

0.10.0

2 files

0.9.0

2 files

0.8.0

2 files

0.7.9

2 files

0.7.8

2 files

0.7.7

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page