Skip to main content

Official Python SDK for the CredEx AI Exchange — the financial exchange for AI compute on XRPL

Project description

credex-sdk

The official Python SDK for the CredEx AI platform — the financial exchange for AI compute on the XRP Ledger.

PyPI version Python 3.9+ License: MIT XRPL Mainnet

Installation

pip install credex-sdk

Quick Start

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

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

# 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

License

MIT License — see LICENSE for details.

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

credex_sdk-0.1.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

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

credex_sdk-0.1.0-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for credex_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 28149d0b19c42e8446491f1119ae71a3b6c91fe616404ccbf916840a0b9a19bb
MD5 4935f280226abc451a6bc2d2b09b7630
BLAKE2b-256 ec64d18f2d83a472aa0da852af6051cadf7afe7df9e36b67eb00018816f09283

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for credex_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d078a4a184b8f5d8610064dbf7832850cab097a5b28374562faf3ca0c7ad9ed7
MD5 fafdfaccce3578e8a91a4d9231b8ad95
BLAKE2b-256 6cc9f10bef686c6d86c06aa9f5a8d4f5dbe020a9e9f672dd34aad2cdafceba3e

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