Agents and SDKs
Python SDK
The same surface as the Node SDK, for Python 3.9 and up. Install agentpay-global, import agentpay.
Install
cURL
pip install agentpay-globalThe distribution is agentpay-global; the import is agentpay. No dependencies beyond the standard library.
Create a client
Python
import os
from agentpay import AgentPay
agentpay = AgentPay(api_key=os.environ["AGENTPAY_API_KEY"])
# optional: base_url="https://api.joomjoo.com", timeout=60.0Resources
Every method returns the parsed JSON as a dict. Keyword arguments mirror the API's field names.
| Method | Endpoint |
|---|---|
cards.create(amount=, merchant=, single_use=, network=, card_name=) | POST /v1/cards |
cards.reveal(card_id) | GET /v1/cards/{id} |
cards.close(card_id) | POST /v1/cards/{id}/close |
spend.get(spend_request_id) | GET /v1/spend/{spend_request_id} |
checkout.create(task=, merchant=, amount=, confirm_pay=, connection_id=, card_holder_name=, start_url=, idempotency_key=) | POST /v1/checkout |
checkout.get(checkout_id) | GET /v1/checkout/{checkout_id} |
connections.create(merchant=, user_ref=) | POST /v1/connections |
connections.complete(connection_id) | POST /v1/connections/{id}/complete |
connections.list() | GET /v1/connections |
connections.get(connection_id) | GET /v1/connections/{id} |
wallet.get() | GET /v1/wallet |
wallet.create_funding_session(amount=, success_url=, cancel_url=) | POST /v1/wallet/funding-sessions |
wallet.declare_bank_transfer(amount=, rail=, currency=, ...) | POST /v1/wallet/bank-transfers |
Example
Python
import os, time
from agentpay import AgentPay, AgentPayError
agentpay = AgentPay(api_key=os.environ["AGENTPAY_API_KEY"])
run = agentpay.checkout.create(
task="buy the domain example.click for 1 year",
merchant="namecheap",
amount=20,
confirm_pay=True,
idempotency_key="order-001",
)
TERMINAL = {"submitted", "canceled", "blocked", "error"}
status = run
while status["status"] not in TERMINAL:
time.sleep(8)
status = agentpay.checkout.get(run["checkout_id"])
print(status["status"], status.get("order_id"), status.get("order_total"))Errors
Any non-2xx response raises AgentPayError with status, code, message and request_id.
Python
try:
agentpay.cards.create(amount=20, merchant="namecheap")
except AgentPayError as e:
print(e.status, e.code, e.request_id)