Metadata-Version: 2.4
Name: tbbn-sdk
Version: 0.2.0
Summary: Python client for the TBBN Platform API — publish listings, manage offers and trade sessions, and verify webhooks.
Author: Trade By Barter Network, Inc.
License: MIT
Project-URL: Homepage, https://tbbnetwork.com
Project-URL: Documentation, https://developer.tbbnetwork.com/merchant/docs/sdks
Project-URL: Changelog, https://github.com/AzaMoney/tbbn/blob/master/packages/sdk-python/CHANGELOG.md
Project-URL: Community, https://developer.tbbnetwork.com/community
Keywords: tbbn,trade by barter,barter,trade,exchange,api,sdk
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.31
Dynamic: license-file

# tbbn-sdk

Python client for the [TBBN Platform API](https://developer.tbbnetwork.com). Publish listings, manage offers and trade
sessions, and verify webhooks. Python 3.10+, type-hinted throughout, `requests` is the only
dependency. Synchronous.

## Install

```bash
pip install tbbn-sdk
```

## Quick start

```python
from tbbn_sdk import TbbnClient

client = TbbnClient(base_url="https://api.tbbnetwork.com", api_key="sk_sandbox_...")

listing = client.listings.upsert({
    "merchantId": "...",
    "merchantListingRef": "sku-1042",
    "sellerId": "...",
    "listingType": "BOTH",
    "title": "Nike Air Max 90 — size 10, lightly worn",
    "category": "Apparel",
    "originalPrice": 150,
    "requestedAmount": 25,
    "currency": "USD",
    "visibility": "GLOBAL",
})

offers = client.offers.list(listing["sellerId"], direction="received")
```

A complete runnable walkthrough is in [`example/basic.py`](./example/basic.py).

## Authentication

Pass either an **API key** (`api_key`, issued to your merchant at
[merchants.tbbnetwork.com](https://merchants.tbbnetwork.com)) or a **session token**
(`access_token`, obtained through one of the `auth` sign-in flows). Sandbox keys
(`sk_sandbox_…`) work against the same API and never touch live data.

## Webhooks

Verify every inbound delivery before trusting it. Pass the raw request body exactly as
received — re-serialising the JSON changes the bytes and the signature will not match.
Signatures are HMAC-SHA256 with a five-minute replay window.

```python
from tbbn_sdk import verify_webhook_signature

ok = verify_webhook_signature(raw_body, request.headers["X-TBBN-Signature"], signing_secret)
```

## Errors

Every non-2xx response throws `TbbnApiError` with `status`, `code`, `request_id`, and the message. Quote the request id when asking
for help with a specific call.

## Resources

`auth`, `merchants`, `api_keys`, `sellers`, `listings`, `catalog`, `media`, `directory`, `search`, `trade_engine`, `currency`, `localization`, `matching`, `recommendations`, `offers`, `trade_sessions`, `checkout`, `billing`, `notifications`, `webhooks`, `audit_logs`, `moderation`, `fraud`, `reputation`, `analytics`, `features`, `sandbox`. Each method maps one-to-one onto an API endpoint documented in the
[API reference](https://developer.tbbnetwork.com/merchant/docs/api).

## Support

Questions and bug reports: the [developer community](https://developer.tbbnetwork.com/community).

## License

MIT © Trade By Barter Network, Inc.
