Skip to main content

Zero-dependency Python client for the agents.u.cash 402 Online Protocol API — non-custodial agent payments (buy + sell).

Project description

agents-u-cash (Python)

Zero-dependency Python client for the agents.u.cash API — the 402 Online Protocol for non-custodial agent payments. Works for both sides of the network: an agent selling (manage resources, watch settlements) and a buyer (fetch a 402 door, push-verify a payment).

Uses only the standard library (urllib). No dependencies. Python 3.7+.

Install

pip install agents-u-cash

Or copy agents_u_cash.py — it has no dependencies.

Sell (as an agent)

from agents_u_cash import AgentsUCash

# Get an API key once (wallet-first; then top up >= $1 to activate):
# key = AgentsUCash().signup(email="me@agent.dev", password="longpass")["api_key"]

agent = AgentsUCash(api_key="...")
agent.set_wallet("btc", "bc1q…")
agent.set_webhook("https://my.bot/webhook")

res = agent.create_resource(amount=0.05)               # priced resource
acc = agent.create_challenge(res["res_id"])             # what a buyer pays
# Share the payable link: https://agents.u.cash/r/{res_id}

settled = agent.get_settlements()                       # your earnings log

Buy (as a buyer)

from agents_u_cash import AgentsUCash

buyer = AgentsUCash()                                   # no key needed to buy
door = buyer.view_door(res_id)                          # the 402 door (JSON)
# 1. pick an entry, pay entry["payTo"] exactly entry["amount"] from your wallet (out of band)
# 2. push-verify with the on-chain tx hash:
result = buyer.verify(door["accepts"][0]["challengeId"], tx_hash)
# -> {"settled": True} | {"status": "pending", "confirmations": n, "required": m}

A human-friendly payable page is also available: buyer.view_door(res_id, html=True) returns the HTML.

API

Method Auth Description
signup(email, password, primary_wallet=None) Register; returns api_key
top_up(amount) key Create a ≥$1 top-up checkout (activates the account)
get_agent() key Account snapshot (balance, wallets, webhook, earnings summary)
set_webhook(url) key Set the settlement webhook
set_wallet(asset, address) key Set your receive address for an asset
set_stripe(secret_key, product_id, webhook_secret, publishable_key=None) key Connect your Stripe account (card rail); verifies the key + product
get_stripe() key Masked Stripe config + the webhook endpoint to register
clear_stripe() key Disconnect your Stripe account
create_resource(amount, currency=None, accepted_assets=None, webhook_url=None) key Create a priced resource
get_resources(res_id=None) key List resources, or fetch one
create_challenge(res_id) key Build the multi-coin accepts[]
verify(challenge_id, hash) key optional Verify + settle (buyer-push: no key needed)
get_settlements() key Earnings log
view_door(res_id, html=False) The public 402 door (JSON, or HTML)

All calls return the parsed response dict and raise AgentsUCashError on API errors (which carries .code and .status).

Error handling

from agents_u_cash import AgentsUCash, AgentsUCashError

try:
    agent.create_resource(amount=0.05)
except AgentsUCashError as e:
    print(e.code, e.status, e)   # e.g. 'uxc_agent_not_activated' 402 ...

Non-custodial: the platform never holds funds — every payTo is the seller's own wallet, and this client never sees your wallet keys.

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

agents_u_cash-0.1.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

agents_u_cash-0.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for agents_u_cash-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0ce1e40767c3a4749ec9ef046865d106ab31036768eab3de54189c2de8fea4dd
MD5 0acadaba8911893149c47ba2b1c2c630
BLAKE2b-256 8cc828808e82f48b14ce8d5ca340196c91c42613694b1dcf57ca16c793345ede

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for agents_u_cash-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7fc35d25c5644087e9aa01416a656c5231dd84723f73bbf339e5c78f5206e181
MD5 3fee7ab9649149058bfa25df94e2a06d
BLAKE2b-256 82d507f162fe79aefebf66c6d0ea7dfa740cd36d858e30bb28956e15f09bcc93

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