Skip to main content

FastAPI gateway for Sardis stablecoin execution

Project description

sardis-api

PyPI version Python 3.11+ License: MIT

FastAPI gateway for Sardis stablecoin execution.

Overview

sardis-api provides a production-ready REST API for the Sardis payment infrastructure:

  • Mandate Processing: AP2 Intent/Cart/Payment mandate ingestion and verification
  • Wallet Operations: Orchestration, approvals, and balance queries
  • Ledger Access: Transaction history and compliance feeds
  • Agent Management: AI agent registration, policies, and spending controls
  • Compliance Integration: KYC/AML hooks and sanction screening

Installation

pip install sardis-api

Development Installation

pip install sardis-api[dev]

Quick Start

import uvicorn
from sardis_api import create_app

# Create the FastAPI application
app = create_app()

# Run the server
if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=8000)

Or use the CLI:

uvicorn sardis_api.main:app --host 0.0.0.0 --port 8000

API Endpoints

Wallets

POST   /api/v2/wallets              Create a new wallet
GET    /api/v2/wallets/{wallet_id}  Get wallet details
GET    /api/v2/wallets/{wallet_id}/balance  Get wallet balance

Transactions

POST   /api/v2/transactions         Initiate a transaction
GET    /api/v2/transactions/{tx_id} Get transaction status
GET    /api/v2/wallets/{wallet_id}/transactions  List wallet transactions

Agents

POST   /api/v2/agents               Register an AI agent
GET    /api/v2/agents/{agent_id}    Get agent details
PATCH  /api/v2/agents/{agent_id}/policy  Update agent policy

Mandates

POST   /api/v2/mandates/intent      Submit an intent mandate
POST   /api/v2/mandates/cart        Submit a cart mandate
POST   /api/v2/mandates/payment     Submit a payment mandate

Holds

POST   /api/v2/holds                Create a payment hold
POST   /api/v2/holds/{hold_id}/capture  Capture a hold
POST   /api/v2/holds/{hold_id}/void     Void a hold

Configuration

Configure via environment variables:

# Database
SARDIS_DATABASE_URL=postgresql://user:pass@localhost/sardis

# Redis (for caching and rate limiting)
SARDIS_REDIS_URL=redis://localhost:6379

# API Settings
SARDIS_API_HOST=0.0.0.0
SARDIS_API_PORT=8000
SARDIS_API_CORS_ORIGINS=["http://localhost:3000"]

# Security
SARDIS_API_KEY_HEADER=X-API-Key
SARDIS_JWT_SECRET=your-secret-key

Middleware

The API includes production-ready middleware:

  • Authentication: API key and JWT validation
  • Rate Limiting: Per-client request throttling
  • Logging: Structured request/response logging
  • Security: CORS, security headers, input validation
  • Exception Handling: Consistent error responses

OpenAPI Documentation

Interactive API documentation is available at:

  • Swagger UI: http://localhost:8000/docs
  • ReDoc: http://localhost:8000/redoc
  • OpenAPI JSON: http://localhost:8000/openapi.json

Architecture

sardis-api/
├── main.py           # Application entry point
├── dependencies.py   # FastAPI dependencies
├── routers/
│   ├── wallets.py    # Wallet endpoints
│   ├── transactions.py
│   ├── agents.py
│   ├── mandates.py
│   ├── holds.py
│   └── ...
└── middleware/
    ├── auth.py       # Authentication
    ├── rate_limit.py # Rate limiting
    ├── logging.py    # Request logging
    └── security.py   # Security headers

Requirements

  • Python 3.11+
  • FastAPI >= 0.109
  • uvicorn >= 0.23
  • sardis-core >= 0.1.0
  • sardis-ledger >= 0.1.0
  • sardis-chain >= 0.1.0
  • sardis-compliance >= 0.1.0

Documentation

Full documentation is available at docs.sardis.io/api.

License

MIT License - see LICENSE for details.

Contributing

Contributions are welcome! Please see our Contributing Guide 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

sardis_api-0.1.0.tar.gz (130.9 kB view details)

Uploaded Source

Built Distribution

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

sardis_api-0.1.0-py3-none-any.whl (133.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for sardis_api-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e16b6282a76faac4c1561f9fa96888815c8d881ed326693743f1a0c2bafeb09c
MD5 898130bdcbcf05d899c5756d788cc51b
BLAKE2b-256 27cc245204dfb445171b0b80cd8757747c091021a99c3c46e762531cd15d8a9e

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for sardis_api-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 031a4d686cd06805801831b555c8b5c960e5c8e5696851df3a8efd80ed845039
MD5 96fb21ff670abea34432ca4ced8c4b6c
BLAKE2b-256 b89287184c42a7cf059f641143dc9eef10204d133c7f04f7f1e9fda06e06e2e0

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