Skip to main content

Python client library for APAL secure P2P communication platform

Project description

APAL Python Client

A Python client library for the APAL secure P2P communication platform.

Installation

pip install apal-client

Quick Start

import asyncio
from apal_client import APALClient
from uuid import UUID

async def main():
    # Initialize client
    client = APALClient(
        base_url="http://localhost:8000",
        email="your@email.com",
        password="your-password"
    )
    
    # Register a new business account
    account = await client.register(
        email="business@example.com",
        password="secure-password",
        business_name="Example Business"
    )
    
    # Send a message
    message = await client.send_message(
        receiver_id=UUID("receiver-uuid"),
        content={
            "type": "payment",
            "data": {
                "amount": 100.00,
                "currency": "USD",
                "payment_method": "bank_transfer",
                "reference_id": "PAY-123456"
            }
        }
    )
    
    # List messages
    messages = await client.list_messages()
    
    # Get message status
    status = await client.get_message_status(message["id"])

if __name__ == "__main__":
    asyncio.run(main())

Features

  • Asynchronous API client
  • Automatic authentication handling
  • Message encryption/decryption
  • Error handling and validation
  • Support for all APAL API endpoints

Environment Variables

The client can be configured using environment variables:

  • APAL_API_KEY: Your API key
  • APAL_EMAIL: Your registered email
  • APAL_PASSWORD: Your password
  • APAL_BASE_URL: API base URL (default: http://localhost:8000)

Error Handling

The client raises custom exceptions for different error cases:

from apal_client import (
    APALError,
    ValidationError,
    AuthenticationError,
    MessageError,
    APIError
)

try:
    await client.send_message(...)
except ValidationError as e:
    print(f"Message validation failed: {e}")
except AuthenticationError as e:
    print(f"Authentication failed: {e}")
except MessageError as e:
    print(f"Message processing failed: {e}")
except APIError as e:
    print(f"API error: {e}")

License

MIT License

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

apal_client-0.1.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

apal_client-0.1.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: apal_client-0.1.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for apal_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d12360fdade16cd31ecc3f449a5a204d6247907b6fe3c07f6718d9789c4a2002
MD5 cf24eb41f48f92d5eabb0fc6043a3a45
BLAKE2b-256 e2111f707f42e91216a823f528dcc21ca7b65b2c163f0386a3a9e0e8ffa4e2cc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: apal_client-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for apal_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9e671d1834e01fa6a3bfeabbd0afca27e25718f80d73c66ae5a9d709039b4d27
MD5 4ff69ad8bc5400c6883d15500ee699e1
BLAKE2b-256 b2c8c1e0671e8385c88e5da975b016255a04c3529cfb32fa39d59e982f0efc6c

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