Metadata-Version: 2.4
Name: dpapay-sdk
Version: 0.1.0
Summary: Python SDK for the dPaPay API — register wallets, list services, create escrows, check XRP balances, and more.
Author-email: dPaPay <dev@dpapay.io>
License: MIT
Project-URL: Homepage, https://dpa-pay-dev.vercel.app
Project-URL: Source, https://github.com/dpapay/dpapay-sdk
Keywords: dpapay,xrp,escrow,payment,blockchain
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Office/Business :: Financial
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.28
Provides-Extra: xrpl
Requires-Dist: xrpl>=2.0.0; extra == "xrpl"

# dPaPay Python SDK

[![PyPI](https://img.shields.io/pypi/v/dpapay-sdk)](https://pypi.org/project/dpapay-sdk/)
[![Python](https://img.shields.io/pypi/pyversions/dpapay-sdk)](https://pypi.org/project/dpapay-sdk/)

A lightweight Python client for the **dPaPay API** — register wallets, list & create services, manage XRP escrows, check fee schedules, and query XRP prices.

dPaPay is a no-account marketplace for buying and selling AI agents, code, data, and tools — with escrow-protected payments and instant settlement on the XRP Ledger.

---

## Installation

```bash
pip install dpapay-sdk
```

Optional XRP Ledger library for advanced operations:

```bash
pip install dpapay-sdk[xrpl]
```

---

## Quick Start

```python
from dpapay import dPaPay

client = dPaPay()
```

---

## Usage

### 1. Register a Wallet

```python
result = client.register("My Trading Bot")
print(result["wallet"]["address"])   # r...
print(result["token"])               # API token (save this!)
```

### 2. List Services

```python
result = client.services.list(limit=10, category="AI")
for svc in result["services"]:
    print(f"{svc['name'][:40]:40s} {svc['price']:>8} XRP  [{svc['category']}]")
print(f"Total: {result['total']}")
```

### 3. Create a Service Listing

```python
svc = client.services.create(
    name="AI Content Generator",
    description="Generates high-quality blog posts using AI",
    price=5.0,
    category="AI",
    agent_id="rXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
)
print(f"Created service {svc['id']}")
```

### 4. XRP Escrow Operations

```python
# Network info
net = client.escrow.network()
print(f"Network: {net['network']}")

# Wallet info / balance
info = client.escrow.wallet("rXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")

# Create escrow (seed-based)
escrow = client.escrow.create(
    buyer_seed="sXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    seller_address="rXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    amount_xrp=10.0,
    finish_after=80000000,
    cancel_after=80001000,
)

# Create escrow (pre-signed transaction blob)
escrow = client.escrow.create_signed(
    job_id="job-001",
    signed_tx_blob="120000...",
    buyer_address="rXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    seller_address="rXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    amount_xrp=10.0,
)

# Check status, finish or cancel
client.escrow.status("tx_hash")
client.escrow.finish("tx_hash")
client.escrow.cancel("tx_hash")
```

### 5. Get Fee Schedule

```python
fees = client.fees.schedule(seller_id="rXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
print(f"Model: {fees['pricing_model']}")
for tier in fees['tiers']:
    print(f"  {tier['label']}: {tier['rate_pct']}%")
```

### 6. Get XRP Price

```python
price = client.xrp.price()
print(f"XRP/USD: ${price['xrp_usd']}")
```

### 7. Submit Feedback

```python
client.feedback.submit(name="Alice", message="Love the platform!")
```

---

## API Reference

| SDK Method | HTTP | Endpoint |
|---|---|---|
| `client.register(label)` | POST | `/api/auth/register` |
| `client.services.list(limit, offset, category)` | GET | `/api/services` |
| `client.services.create(name, desc, price, category, agent_id)` | POST | `/api/services` |
| `client.escrow.create(buyer_seed, seller_address, amount_xrp, finish_after, cancel_after)` | POST | `/api/escrow?action=create` |
| `client.escrow.create_signed(job_id, signed_tx_blob, buyer_address, seller_address, amount_xrp)` | POST | `/api/escrow?action=create` |
| `client.escrow.finish(tx_hash)` | POST | `/api/escrow?action=finish` |
| `client.escrow.cancel(tx_hash)` | POST | `/api/escrow?action=cancel` |
| `client.escrow.status(tx_hash)` | POST | `/api/escrow?action=status` |
| `client.escrow.wallet(address)` | GET | `/api/escrow?action=wallet` |
| `client.escrow.network()` | GET | `/api/escrow?action=network` |
| `client.fees.schedule(seller_id)` | GET | `/api/payments?action=myfee` |
| `client.xrp.price()` | GET | `/api/payments?action=prices` |
| `client.feedback.submit(name, message)` | POST | `/api/feedback` |

---

## Development

```bash
git clone https://github.com/dpapay/dpapay-sdk.git
cd dpapay-sdk
pip install -e .
```

---

## License

MIT
