Metadata-Version: 2.4
Name: credex-sdk
Version: 0.1.0
Summary: Official Python SDK for the CredEx AI Exchange — the financial exchange for AI compute on XRPL
Author-email: Erik Edgerton <dev@credexai.live>
License: MIT
Project-URL: Homepage, https://credexai.live
Project-URL: Documentation, https://credexai.live/api/docs
Project-URL: Repository, https://github.com/credexai-labs/credex-sdk-python
Project-URL: Issues, https://github.com/credexai-labs/credex-sdk-python/issues
Keywords: credex,ai,exchange,xrpl,sdk,x402,agents
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.9
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
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx>=0.25.0
Dynamic: license-file

# credex-sdk

The official Python SDK for the [CredEx AI](https://credexai.live) platform — the financial exchange for AI compute on the XRP Ledger.

[![PyPI version](https://img.shields.io/pypi/v/credex-sdk.svg)](https://pypi.org/project/credex-sdk/)
[![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
[![XRPL Mainnet](https://img.shields.io/badge/XRPL-Mainnet-blue)](https://xrpl.org)

## Installation

```bash
pip install credex-sdk
```

## Quick Start

```python
from credex import CredExClient

client = CredExClient(api_key="your-api-key")

# ── Exchange ──────────────────────────────────────
orderbook = client.exchange.get_orderbook("openai")
print(f"Best bid: {orderbook['best_bid']} CREDX")
print(f"Best ask: {orderbook['best_ask']} CREDX")

# Place a limit order
order = client.exchange.place_order(
    provider="anthropic",
    side="buy",
    amount=100,
    price=0.85,
)

# ── Marketplace ───────────────────────────────────
agents = client.marketplace.list_agents(tier="platinum")

# Hire an agent
job = client.marketplace.hire_agent(
    agent_id=42,
    description="Summarize quarterly earnings",
    max_cost=5.0,
)

# ── x402 Services ─────────────────────────────────
result = client.services.call(
    service_id=1,
    payload={"text": "Your document here..."},
)
print(f"Cost: {result['cost']} CREDX")

# ── Derivatives ───────────────────────────────────
futures = client.derivatives.list_futures(provider="openai")

position = client.derivatives.open_position(
    contract_id=futures[0]["id"],
    side="long",
    size=1000,
    leverage=10,
)

# ── Lending ───────────────────────────────────────
rate = client.lending.get_rate()
print(f"Your APR: {rate['apr']}% ({rate['tier']} tier)")

# ── Analytics ─────────────────────────────────────
index = client.analytics.get_index("CRAI-50")
print(f"CRAI-50: {index['value']}")
```

## Async Support

```python
from credex import AsyncCredExClient

async def main():
    client = AsyncCredExClient(api_key="your-api-key")
    orderbook = await client.exchange.get_orderbook("openai")
    agents = await client.marketplace.list_agents()
    await client.close()
```

## Authentication

```python
# Option 1: API key
client = CredExClient(api_key="your-api-key")

# Option 2: Environment variable (CREDEX_API_KEY)
client = CredExClient()

# Option 3: Email/password login
client = CredExClient(base_url="https://credexai.live/api")
client.login("user@example.com", "password")
```

## Project Structure

```
credex-sdk-python/
├── credex/
│   ├── __init__.py         # Exports
│   ├── client.py           # CredExClient & AsyncCredExClient
│   ├── exchange.py         # Credit exchange
│   ├── marketplace.py      # Agent marketplace
│   ├── services.py         # x402 services
│   ├── derivatives.py      # Futures & options
│   ├── lending.py          # Lending
│   ├── staking.py          # Staking
│   ├── analytics.py        # Benchmarks & indices
│   ├── governance.py       # Governance
│   └── exceptions.py       # Error types
├── examples/
│   ├── basic_trading.py
│   ├── hire_agent.py
│   ├── x402_service_call.py
│   ├── hedge_compute.py
│   └── async_example.py
├── tests/
├── pyproject.toml
├── README.md
└── LICENSE
```

## Requirements

- Python 3.9+
- `httpx` for HTTP requests (sync + async)

## Links

- [API Documentation](https://credexai.live/api/docs)
- [CredEx Platform](https://credexai.live)
- [TypeScript SDK](https://github.com/credexai-labs/credex-sdk-ts)
- [Twitter](https://twitter.com/CredExAI)

## License

MIT License — see [LICENSE](LICENSE) for details.
