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://<your-biznet-api-host>")

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, a separate host from the main 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 per-merchant 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.1.tar.gz (24.1 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.1-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: biznet-0.1.1.tar.gz
  • Upload date:
  • Size: 24.1 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.1.tar.gz
Algorithm Hash digest
SHA256 68e52966ef46f3f93511d98fe20cb0ff8ee608f341dd59b02ad8d22db286e3b8
MD5 7d2445ecfde4f654ac16f9e2230dd153
BLAKE2b-256 bb4e31c40e35bac72ebbc9801b8f21e3bdf39dcd07a4b86a618beec49c948a3e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: biznet-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 23.9 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 59e89bc0a71f4de71b14a1eac04787497ba997e3a0ebbb0ef25ef44e338e6aa5
MD5 4befde015d18ad242dc88e8dacb1340e
BLAKE2b-256 099a5d31dcfa07a3751c2ee5aca819d6eb227d754afe1bbf0d6c85d545ff1bef

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