Skip to main content

Python SDK for Fountain stablecoin API

Project description

Fountain SDK - Python

Official Python client for the Fountain stablecoin API.

Features

  • Email-based authentication with JWT tokens
  • Complete API coverage with 18 methods
  • Full type hints for IDE support
  • Automatic token management
  • Comprehensive error handling
  • Admin dashboard endpoints
  • Real-time operation monitoring

Installation

pip install fountain-sdk

Quick Start

from fountain_sdk import FountainSDK

# Initialize client
fountain = FountainSDK('http://localhost:3000')

# Login
login = fountain.login('user@example.com')
print(f"Welcome, {login.company_name}!")

# Create a new stablecoin operation
operation = fountain.create_stablecoin(
    currency_code='APBRL',
    amount_brl=10000.00,
    deposit_type='XRP',
    webhook_url='https://yourapi.com/webhook'
)
print(f"Operation created: {operation.id}")

# Check operation status
status = fountain.get_operation(operation.id)
print(f"Status: {status.status}")

# Mint more tokens
more = fountain.mint_more(
    stablecoin_id=operation.stablecoin_id,
    amount_brl=5000.00,
    deposit_type='XRP'
)

# Burn tokens
burn = fountain.burn_stablecoin(
    stablecoin_id=operation.stablecoin_id,
    amount_tokens=1000.00,
    return_asset='XRP'
)

Authentication

Login with Email

fountain = FountainSDK('http://localhost:3000')

# Login
login_response = fountain.login('admin@company.com')

# Token is automatically set
print(f"Token expires at: {login_response.expires}")
print(f"Is admin: {login_response.is_admin}")

Manual Token Management

# Set token manually
fountain.set_token('your-jwt-token-here')

# Check if authenticated
if fountain.is_authenticated():
    token = fountain.get_token()
    print(f"Current token: {token}")

# Logout
fountain.logout()

API Methods

Authentication

  • login(email) - Login with email
  • set_token(token) - Set JWT token
  • get_token() - Get current token
  • logout() - Clear token
  • is_authenticated() - Check authentication status

Stablecoin Operations

  • create_stablecoin(currency_code, amount_brl, deposit_type, company_wallet, webhook_url)
  • mint_more(stablecoin_id, amount_brl, deposit_type, webhook_url)
  • burn_stablecoin(stablecoin_id, amount_tokens, return_asset)
  • get_stablecoin(stablecoin_id)

Operation Monitoring

  • get_operations(limit, offset) - Get operations for current company
  • get_operation(operation_id) - Get specific operation
  • get_temp_wallet_status(operation_id) - Monitor temp wallet progress

Admin Methods

  • get_admin_statistics() - Get system statistics
  • get_admin_companies(limit, offset) - List all companies
  • get_admin_stablecoins(limit, offset) - List all stablecoins
  • get_admin_stablecoin_by_code(currency_code) - Get stablecoin by code
  • get_admin_temp_wallets(limit, offset) - Monitor all temp wallets
  • get_admin_operations(limit, offset) - View all operations
  • get_admin_company_stablecoins(company_id, limit, offset) - Get company stablecoins
  • get_admin_company_operations(company_id, limit, offset) - Get company operations

Error Handling

from fountain_sdk import (
    FountainSDK,
    AuthenticationError,
    APIError,
    ValidationError,
)

fountain = FountainSDK('http://localhost:3000')

try:
    login = fountain.login('user@example.com')
except ValidationError as e:
    print(f"Invalid input: {e}")
except AuthenticationError as e:
    print(f"Authentication failed: {e}")
except APIError as e:
    print(f"API error: {e}")
    print(f"Status code: {e.status_code}")

Data Models

All responses are typed with dataclasses:

  • LoginResponse - Login response with JWT
  • OperationDetails - Mint/burn operation details
  • TempWalletStatus - Temporary wallet monitoring
  • AdminStatistics - System statistics
  • Company - Company information
  • Stablecoin - Stablecoin details
  • TempWallet - Temporary wallet details
  • DepositHistory - Deposit transaction record

Development

Install dependencies

pip install -r requirements-dev.txt

Run tests

pytest
pytest --cov=fountain_sdk  # With coverage

Format code

black fountain_sdk/

Type checking

mypy fountain_sdk/

License

MIT License - See LICENSE file for details

Support

For issues and questions, visit: https://github.com/xrpl-fountain/fountain-sdk-python/issues

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

fountain_sdk-1.0.1.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

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

fountain_sdk-1.0.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file fountain_sdk-1.0.1.tar.gz.

File metadata

  • Download URL: fountain_sdk-1.0.1.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fountain_sdk-1.0.1.tar.gz
Algorithm Hash digest
SHA256 b1e8bf23ac0b3ef0eab8be5bbd3884ce22c2a93dbee7f5c5fcb99e3a213940bb
MD5 8c80b4a3f17c0f10b626f3ae2fe475e8
BLAKE2b-256 4f523c8ad476c21ed4d4fcd2f96c27789919b5b54802a897bb96265ac8473acf

See more details on using hashes here.

File details

Details for the file fountain_sdk-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: fountain_sdk-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fountain_sdk-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 76028c119403afaa8fbb9f2f2db2dc29b80b08d228b98e03ade2a44d84be3d47
MD5 cfd6c661cd8f2e5092c5e45b9edf0252
BLAKE2b-256 ad9c01b991fac91a28f2cbed54e4b94d2ee601b51bc1ec4c7fa1463382ff4604

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