Skip to main content

Python SDK for the Platform5 Developer API — send SMS, email, and more

Project description

platform5-sdk

Python SDK for the Platform5 Developer API.

Install

pip install platform5-sdk

Usage

from platform5 import Platform5

client = Platform5(api_key="p5_live_abc123def456")

# Send an SMS
resp = client.sms.send(
    to="+254712345678",
    message="Your appointment is confirmed for tomorrow at 10 AM.",
    from_="MyBrand",
)
print(resp.message_id, resp.parts, resp.cost)

# Send an email
client.email.send(
    to="user@example.com",
    subject="Welcome to Platform5",
    body="Hello, thank you for signing up!",
    from_="MyBrand",
)

# Check message status
status = client.messages.get("msg-uuid")
print(status.status)

# Check balance
balance = client.account.get_balance()
print(balance.available_balance, balance.currency)

Configuration

Platform5(
    api_key="p5_live_abc123",
    base_url="http://localhost:8084",  # optional, defaults to http://localhost:8084
)

Services

Method Endpoint
client.sms.send(to, message, from_) POST /v1/sms/send
client.email.send(to, subject, body, from_, body_type?) POST /v1/email/send
client.messages.get(id) GET /v1/messages/{id}
client.account.get_balance() GET /v1/balance
client.health() GET /health

Error Handling

from platform5.errors import (
    UnauthorizedError,
    InsufficientBalanceError,
    ForbiddenError,
    NotFoundError,
    ValidationError,
    RateLimitError,
    Platform5Error,
)

try:
    client.sms.send(to="+2547", message="Hello", from_="MyBrand")
except RateLimitError as e:
    print(f"Rate limited: {e.remaining}/{e.limit}")
except Platform5Error as e:
    print(f"API error {e.status_code}: {e}")

Idempotency

sms.send() and email.send() automatically generate a UUID Idempotency-Key header for every request.

Requirements

  • Python 3.10+

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

platform5_sdk-0.1.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

platform5_sdk-0.1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: platform5_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for platform5_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a62c00fb5c4d4fe62ef83f19a626d9e78c56586f21628dec81f7fdf760154f00
MD5 a959b6be7e06ca7896ae7d8749c83872
BLAKE2b-256 32024198239d835ce8c88908d382ada328c4a8cfd44fd909e270c681ab114c66

See more details on using hashes here.

Provenance

The following attestation bundles were made for platform5_sdk-0.1.0.tar.gz:

Publisher: release.yml on nixoncode/platform5-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: platform5_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for platform5_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bf49fffa9cf87d3233665c9a3e93da87c13b4e31d09341d80f5e109e77b231c2
MD5 9849cf74fb4220a75364784aeab2c28c
BLAKE2b-256 42af27ac967fcf81530626637b6e5c9bc353a77b6f48008b71e1f4cb12be8951

See more details on using hashes here.

Provenance

The following attestation bundles were made for platform5_sdk-0.1.0-py3-none-any.whl:

Publisher: release.yml on nixoncode/platform5-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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