Skip to main content

Python SDK for the BizNetAI merchant API

Project description

biznet

Python SDK for the BizNetAI merchant API. Part of ConsumerGenie Corporation.

Install

pip install biznet

Usage

from biznet import BizNet

client = BizNet(api_key="sk_live_...", base_url="https://<api-id>.execute-api.us-east-2.amazonaws.com")

Both values fall back to environment variables: BIZNET_API_KEY and BIZNET_BASE_URL.

An async client is available as AsyncBizNet with the same constructor.

Resources available now:

client.users.me()          # GET  /v1/users/me
client.users.status()      # GET  /v1/users/me/status
client.users.deactivate()  # DELETE /v1/users/me

client.keys.issue(env="test", scopes=[])  # POST /v1/keys, returns the secret once
client.keys.list()                        # GET  /v1/keys
client.keys.revoke(key_id)                # DELETE /v1/keys/{key_id}

client.products.create(title, description, price)  # POST /v1/products -> Product
client.products.get(product_id)                    # GET  /v1/products/{id} -> Product
client.products.delete(product_id)                 # DELETE, soft delete
job_id = client.products.bulk_create([{...}])      # POST /v1/products/bulk

client.jobs.status(job_id)                # GET /v1/jobs/{id} -> Job
client.jobs.wait(job_id, timeout=300)     # poll with backoff until done/failed

client.adapters.connect("woocommerce", store_url=..., consumer_key=..., consumer_secret=...)
job_id = client.adapters.sync("woocommerce")       # POST .../sync
client.adapters.sync_status("woocommerce", job_id) # GET .../sync/status -> Job

client.policies.upload("returns.md")      # multipart; path or (name, bytes)
client.policies.list()                    # GET /v1/rag/policies
client.policies.delete("returns.md")      # DELETE by filename

Chat, UCP, and deploy live on the Merchant-node service (Cloud Run), a separate host from the AWS API. Set node_url on the client or BIZNET_NODE_URL:

client.chat.complete(session_id, message)        # POST {node}/chat-sync
async for event in aclient.chat.stream(session_id, message):
    ...                                          # typed SSE events

client.ucp.configure(slug, business_name, stripe_account_id)
client.ucp.status()

client.deploy.shared()      # provision on shared infra (default)
client.deploy.dedicated()   # dedicated Cloud Run services
client.deploy.status()
client.deploy.deprovision()

biznet.resources.deploy.create_ucp_router(api_key) returns a FastAPI router serving GET /.well-known/ucp on a merchant's own domain (requires fastapi).

MerchantNode

Run an MCP server on your own infra. Override only what your system supports; the 8 operational tools ship with mock defaults, and the 4 UCP checkout tools call the BizNet UCP service (set BIZNET_UCP_URL). Requires the mcp extra: pip install "biznet[mcp]".

from biznet import MerchantNode

class MyStore(MerchantNode):
    async def get_stock_level(self, product_id: str) -> int:
        return my_inventory.count(product_id)

MyStore(api_key="sk_live_...").run()  # stdio; or run(transport="sse")

CLI

biznetai deploy finds the MerchantNode subclass in the current directory, packages it with requirements.txt, and provisions it on BizNet infrastructure:

export BIZNET_API_KEY=sk_live_...
export BIZNET_NODE_URL=https://<merchant-node-host>
biznetai deploy                 # shared infra (default)
biznetai deploy --tier dedicated

It streams provisioning status and prints the service URLs when live.

Behavior

  • Every request carries X-API-Key. Set client.api_key to rotate the key in place.
  • Every request carries an X-Request-Id (uuid4). The same id is reused across retries and echoed back by the server for tracing.
  • 429 and 5xx responses retry up to 3 attempts with jittered exponential backoff.
  • Non-2xx responses raise typed exceptions mapped from the API error envelope {code, message, request_id}: AuthError, NotFoundError, ValidationError, RateLimitError, InternalError.
  • SSE chat streams parse into typed StreamEvents: text, products, checkout, tool_call, error, done.

Development

python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest

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

biznet-0.1.0.tar.gz (24.2 kB view details)

Uploaded Source

Built Distribution

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

biznet-0.1.0-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

Details for the file biznet-0.1.0.tar.gz.

File metadata

  • Download URL: biznet-0.1.0.tar.gz
  • Upload date:
  • Size: 24.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.8

File hashes

Hashes for biznet-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b1cbf60ef9396d91604228c5bc46e3b6034d5becab41516176ed42541c7b5eb7
MD5 d94b036babd51dbac99e4b848f5ba0cb
BLAKE2b-256 3246fac92e4d813a58c8cbc2c91c632e93a259f67f202c3d09c8c3498676d639

See more details on using hashes here.

File details

Details for the file biznet-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: biznet-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.8

File hashes

Hashes for biznet-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ad5d0806ab087e96087ace35a3d7591b82389559836d10a9ff91dc9f7f83e395
MD5 69f9779709d38a8060114778b8f08ebc
BLAKE2b-256 7628e6c257f79a53da6a157a027031ef95178c6803f414e253e6e9b674aaa341

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