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.2.tar.gz (148.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.2-py3-none-any.whl (190.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wbapi_async-1.0.2.tar.gz
  • Upload date:
  • Size: 148.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.2.tar.gz
Algorithm Hash digest
SHA256 b8e3cd0c82cac6bef0b21c07e49ef62d5e33af3699013d87327fadb3542490b4
MD5 bff72f046cf485ec4a5b17850e1d7aa6
BLAKE2b-256 8b6ddb2b2c98794d5240c5b58830317a8b8466e96fc80b59b4aa4698b188b727

See more details on using hashes here.

Provenance

The following attestation bundles were made for wbapi_async-1.0.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: wbapi_async-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 190.8 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f2d007e70745e220651d685e6917738f9595c4b28016b2c634132dd8c2bf8621
MD5 abd2dea47be3fb0f6fb5bee78c2724a9
BLAKE2b-256 20a8b60598ce6c783b178ed974d1c35544c2a0db04f3d1ae86a6785d67d3f068

See more details on using hashes here.

Provenance

The following attestation bundles were made for wbapi_async-1.0.2-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

This release

1.0.2 This release

2 files

1.0.1

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