Skip to main content

Official Python SDK for the Phoenix BaaS platform

Project description

phoenix-baas-sdk

Official Python SDK for the Phoenix BaaS platform — AI-powered banking infrastructure for Africa.

Installation

pip install phoenix-baas-sdk

Requires Python 3.11+. The only dependency is httpx.

Quickstart

import phoenix_sdk as phoenix

client = phoenix.Client(api_key="sk_test_...")

# 1. Create a customer
customer = client.customers.create(
    "Amara Okafor",
    email="amara@example.com",
    phone="+2348012345678",
)

# 2. Score them with Eye (AI credit engine)
decision = client.eye.score(
    customer.id,
    requested_amount=500_000_00,   # ₦500,000 in kobo
    tenor_months=12,
    open_banking=phoenix.OpenBankingData(
        avg_monthly_inflow=200_000_00,
        salary_detected=True,
        bounce_count=0,
    ),
)
print(decision.outcome)   # "approve" | "refer" | "decline"
print(decision.pd)        # e.g. 0.042
print(decision.reasons[0].human_readable)  # "Strong salary history"

# 3. Apply for a loan (Rise)
if decision.outcome == "approve":
    loan = client.loans.apply(
        customer.id,
        requested_amount=500_000_00,
        tenor_months=12,
        eye_application_id=decision.application_id,
    )
    loan = client.loans.disburse(loan.id, disbursement_reference="TXN_001")
    print(loan.schedule[0].due_date)

Async usage

import asyncio
import phoenix_sdk as phoenix

async def main():
    async with phoenix.AsyncClient(api_key="sk_test_...") as client:
        customer = await client.customers.create("Amara Okafor")
        decision = await client.eye.score(customer.id, requested_amount=500_000_00, tenor_months=12)
        print(decision.outcome, decision.pd)

asyncio.run(main())

Resources

Resource Methods
client.customers create, get, update, list
client.eye score, get_decision, fraud_check, categorise
client.loans apply, get, disburse, record_payment, list
client.accounts open, get, transfer, transactions, list
client.shield list_alerts, resolve_alert

Configuration

client = phoenix.Client(
    api_key="sk_test_...",
    base_url="https://api.getphoenix.io",   # default
    eye_url="https://eye.getphoenix.io",    # default
    timeout=30.0,                           # seconds
)

Set base_url and eye_url to http://localhost:8001 / http://localhost:8000 for local development.

Error handling

from phoenix_sdk.exceptions import AuthError, NotFoundError, PhoenixError

try:
    customer = client.customers.get("cust_nonexistent")
except NotFoundError:
    print("Customer not found")
except AuthError:
    print("Invalid API key")
except PhoenixError as e:
    print(f"API error {e.status_code}: {e}")
Exception HTTP status
AuthError 401
ForbiddenError 403
NotFoundError 404
ConflictError 409
ValidationError 422
ServiceUnavailableError 503

License

MIT

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

phoenix_baas_sdk-0.2.1.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

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

phoenix_baas_sdk-0.2.1-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file phoenix_baas_sdk-0.2.1.tar.gz.

File metadata

  • Download URL: phoenix_baas_sdk-0.2.1.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for phoenix_baas_sdk-0.2.1.tar.gz
Algorithm Hash digest
SHA256 ae84a040d936d566d90397ab21703c0814d7ef8229e40b9c52fe83c14c4899d4
MD5 a04bf090a24c295204996791545dfe32
BLAKE2b-256 13723125ed18068f4ebbb30113c657e7654c0035879c632cb8ba00f6fbaaf2ba

See more details on using hashes here.

File details

Details for the file phoenix_baas_sdk-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for phoenix_baas_sdk-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 12884e17b035619877e2b2f7c8135330bcd32959bac2f743bc1312315c678f20
MD5 dd4679603baddf7c020277756b1b5187
BLAKE2b-256 f2dc463df68711334bb88c4984245efbd7af1f7ffa7c37d453c04a3798a806cc

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