Skip to main content

Python SDK for DevHub API

Project description

DevHub Python SDK

PyPI version Python Support Documentation License: MIT

A Python SDK for the DevHub API, supporting SMS, Email, WhatsApp, RCS, and Contact management.

Features

  • Multi-channel communication: SMS, Email, WhatsApp, RCS
  • Contact management: Create, update, and manage contacts
  • Unified messaging: View and manage messages across all channels
  • Sync-first design: Simple, blocking API calls
  • Type safety: Full Pydantic model support with type hints
  • Minimal dependencies: Only requires requests and pydantic
  • Python 3.8+ support: Compatible with modern Python versions

Installation

pip install devhub-python

Quick Start

from devhub_python import DevoClient

# Initialize the client
client = DevoClient(api_key="your-api-key")

# Send an SMS
sms_response = client.sms.send_sms(
    recipient="+1234567890",
    message="Hello, World!",
    sender="+1987654321"
)
print(f"SMS sent with ID: {sms_response.id}")

# Send an email
email_response = client.email.send_email(
    recipient="recipient@example.com",
    subject="Hello from Devo!",
    content="This is a test email from the Devo SDK.",
    sender_email="sender@example.com"
)
print(f"Email sent with ID: {email_response.id}")

# Send a WhatsApp message
whatsapp_response = client.whatsapp.send_text_message(
    recipient="+1234567890",
    message="Hello via WhatsApp!"
)
print(f"WhatsApp message sent with ID: {whatsapp_response.id}")

Authentication

The SDK uses API key authentication:

from devhub_python import DevoClient

client = DevoClient(api_key="your-api-key")

Configuration

Client Configuration

client = DevoClient(
    api_key="your-api-key",
    timeout=30.0,  # Optional: request timeout
)

Custom Session

You can provide your own requests.Session for advanced configuration:

import requests
from devhub_python import DevoClient

session = requests.Session()
session.proxies = {"https": "https://proxy.example.com:8080"}

client = DevoClient(
    api_key="your-api-key",
    session=session
)

Models

All API responses are returned as Pydantic models with full type support. The SDK includes models for:

  • SMS: SMSQuickSendResponse, SenderInfo, AvailableNumber
  • Email: EmailSendResponse, EmailTemplateResponse
  • WhatsApp: WhatsAppTextResponse, WhatsAppMediaResponse
  • RCS: RCSMessage, RcsSendMessageSerializer
  • Contacts: ContactSerializer, CreateContactDto, UpdateContactDto
  • Contact Groups: ContactsGroup, CreateContactsGroupDto

Example usage:

# All responses are typed Pydantic models
sms_response = client.sms.send_sms(recipient="+1234567890", message="Hello", sender="+1987654321")
print(f"Message ID: {sms_response.id}")  # Type-safe access
print(f"Status: {sms_response.status}")

Development

Setting up the development environment

# Clone the repository
git clone https://github.com/devotel/devhub-python.git
cd devhub-python

# Install development dependencies
pip install -e ".[dev]"

# Install pre-commit hooks
pre-commit install

Running tests

# Run all tests
pytest

# Run with coverage
pytest --cov=src/devhub_python

# Run specific test file
pytest tests/test_sms.py

Code formatting

# Format code with black
black src/ tests/

# Sort imports with isort
isort src/ tests/

# Run type checking with mypy
mypy src/

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests and linting
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

Changelog

See CHANGELOG.md for details about changes in each version.

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

devhub_python-0.1.0.tar.gz (52.2 kB view details)

Uploaded Source

Built Distribution

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

devhub_python-0.1.0-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for devhub_python-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a22828e0052d35b8b301da39401d6291f305dfc9413227a4a6580f3e8884f630
MD5 27d7ffdb9e48e0613f9f192af7d82751
BLAKE2b-256 e1c97eb1ff54628058994a86c4eff66663137dd77027736a334e5c16a32213e0

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for devhub_python-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f77d5319bf07207a720327e7a79efaa5acb77632f03eff58a72e96b5ab8e06de
MD5 084921c3b55ef47d1436d88b062a6658
BLAKE2b-256 2353aba34fb19f54478d46ab8b1a0eb0273ed8a9bac3449a5d454cfcac1dbd46

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