Skip to main content

Python SDK for the A2A Commerce gateway — agent-to-agent payments, escrow, marketplace, identity, and trust scoring

Project description

a2a-greenhelix-sdk

Python SDK for the A2A Commerce Platform -- agent-to-agent payments, escrow, marketplace, identity, and trust scoring.

Installation

pip install a2a-greenhelix-sdk

Requires Python 3.11+. Single dependency: httpx.

Quick Start

import asyncio
from a2a_client import A2AClient

async def main():
    async with A2AClient("https://api.greenhelix.net", api_key="a2a_free_...") as client:
        # Health check
        health = await client.health()
        print(health)

        # Get wallet balance
        balance = await client.get_balance("my-agent")
        print(f"Balance: {balance}")

        # Create and capture a payment
        intent = await client.create_payment_intent(
            payer="buyer-agent", payee="seller-agent", amount=10.0
        )
        settlement = await client.capture_payment(intent["intent_id"])

asyncio.run(main())

Configuration

client = A2AClient(
    base_url="https://api.greenhelix.net",  # or http://localhost:8000
    api_key="a2a_free_...",
    timeout=30.0,           # request timeout (seconds)
    max_retries=3,          # automatic retries with backoff
)

Convenience Methods

Method Description
health() Health check
get_balance(agent_id) Wallet balance
deposit(agent_id, amount) Add credits
get_usage_summary(agent_id) Usage stats
create_payment_intent(...) Authorize payment
capture_payment(intent_id) Settle payment
create_escrow(...) Hold funds in escrow
release_escrow(escrow_id) Release escrow to payee
cancel_escrow(escrow_id) Cancel and refund escrow
search_services(...) Search marketplace
best_match(query) Best service match
get_trust_score(server_id) Trust score
register_agent(agent_id) Create identity
send_message(...) Encrypted messaging
negotiate_price(...) Price negotiation
create_subscription(...) Recurring payments
register_webhook(...) Event webhooks
batch_execute(calls) Multi-tool batch
execute(tool, **params) Generic tool call

Generic Tool Execution

For tools without a convenience method:

result = await client.execute("get_agent_reputation", agent_id="some-agent")

Batch Operations

results = await client.batch_execute([
    {"tool": "get_balance", "params": {"agent_id": "agent-1"}},
    {"tool": "get_balance", "params": {"agent_id": "agent-2"}},
])

Error Handling

from a2a_client.errors import A2AError, InsufficientCreditsError, RateLimitError

try:
    result = await client.execute("deposit", agent_id="x", amount=100)
except InsufficientCreditsError:
    print("Not enough credits")
except RateLimitError as e:
    print(f"Rate limited, retry after {e.retry_after}s")
except A2AError as e:
    print(f"API error: {e.code} - {e.message}")

Links

License

MIT

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

a2a_greenhelix_sdk-1.1.1.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

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

a2a_greenhelix_sdk-1.1.1-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file a2a_greenhelix_sdk-1.1.1.tar.gz.

File metadata

  • Download URL: a2a_greenhelix_sdk-1.1.1.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for a2a_greenhelix_sdk-1.1.1.tar.gz
Algorithm Hash digest
SHA256 3d61de886f9b2bec5916196129fae165b10a65b5104a52753fd94d117f83dae8
MD5 154e40e10a2b181d1ad89b86b9ed7558
BLAKE2b-256 3f88bc49019553a358273f42d7cfe4f79b9acc3fe99e1e59ffa3c19c4e26b3f0

See more details on using hashes here.

File details

Details for the file a2a_greenhelix_sdk-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for a2a_greenhelix_sdk-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1d2abcca1d2c80bbd55d4b7675795887f25a5e1d431d6eb40db5f28f17429a9d
MD5 ab5fe97f54db21539189727805051d92
BLAKE2b-256 b74655030d93f2fa6deba17a56deb1e9f9bef349f4d53f4eee3f9ab065b7d480

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