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.0.tar.gz (133.0 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.0-py3-none-any.whl (176.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: wbapi_async-1.0.0.tar.gz
  • Upload date:
  • Size: 133.0 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.0.tar.gz
Algorithm Hash digest
SHA256 9e3aa6a8c3581f0f3d93568d248201a70c3d9f2207ab4c3565491558893fc4a6
MD5 0a44da9cfc3f2d596f99dfd30f97272e
BLAKE2b-256 b394a570020f0376dbd8b65a448fc2ed51853b0e10c402feea867d15af4659d9

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: wbapi_async-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 176.2 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e8cf73f26c7b89e60d1f7d3e9c69e6359711b0adc1b5e297d43b8e69c9ee1da6
MD5 46803cd83f1905c146dcb851efaeb9c1
BLAKE2b-256 7839b785178c1c81e5f2209298d7b6a7156ba04ffe946a23e521be395ba3dec3

See more details on using hashes here.

Provenance

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

1.0.1

2 files

This release

1.0.0 This release

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