Skip to main content

Official Trimis SDK for Python - Send emails, push notifications, and chat messages

Project description

Trimis Python SDK

Official Python SDK for Trimis.ro - Send emails, push notifications, and chat messages.

Installation

pip install trimis-python

Quick Start

from trimis import TrimisClient

client = TrimisClient("YOUR_API_KEY")

# Send an email
result = client.send_email(
    to="recipient@example.com",
    from_email="sender@yourdomain.com",
    subject="Hello!",
    html="<h1>Hello World</h1>",
    text="Hello World"
)

if result["success"]:
    print("Email sent!", result["data"])
else:
    print("Error:", result["error"])

Email API

# Send email
result = client.send_email(
    to="user@example.com",
    from_email="noreply@yourdomain.com",
    subject="Welcome!",
    html="<h1>Welcome</h1>",
    text="Welcome",
    track_opens=True,
    track_clicks=True
)

Notification Hub API

# Send notification with template
result = client.send_notification(
    to="user@example.com",
    from_email="noreply@yourdomain.com",
    template="welcome_email",
    variables={
        "name": "John Doe",
        "activation_link": "https://app.com/activate?token=abc123"
    }
)

# Get notification status
notification = client.get_notification("notif_123")

Push Notifications API

# Get VAPID key
vapid = client.get_vapid_key()

# Subscribe user
client.subscribe_push(
    user_id="user123",
    platform="web",
    subscription={
        "endpoint": "https://fcm.googleapis.com/...",
        "keys": {
            "p256dh": "...",
            "auth": "..."
        }
    }
)

# Send push notification
client.send_push(
    user_ids=["user123", "user456"],
    title="New Message",
    body="You have a new message",
    url="https://app.com/messages"
)

Chat API

# Create conversation
conversation = client.create_conversation(
    conversation_type="direct",
    participants=[
        {"user_id": "user1", "name": "Alice"},
        {"user_id": "user2", "name": "Bob"}
    ]
)

# Send message
client.send_message(
    conversation_id=conversation["data"]["conversation_id"],
    sender_id="user1",
    content="Hello!"
)

# Get messages
messages = client.get_messages(conversation["data"]["conversation_id"])

# Mark as read
client.mark_message_read("msg_123", "user2")

Django Integration

# settings.py
TRIMIS_API_KEY = os.getenv("TRIMIS_API_KEY")

# In your views or tasks
from trimis import TrimisClient

client = TrimisClient(settings.TRIMIS_API_KEY)
client.send_email(...)

Flask Integration

from flask import Flask
from trimis import TrimisClient

app = Flask(__name__)
app.config["TRIMIS_API_KEY"] = os.getenv("TRIMIS_API_KEY")

client = TrimisClient(app.config["TRIMIS_API_KEY"])

Error Handling

result = client.send_email(...)

if not result["success"]:
    print(f"Error: {result['error']}")
    print(f"Status: {result.get('status')}")

License

MIT

Links

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

trimis_python-1.0.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

trimis_python-1.0.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file trimis_python-1.0.0.tar.gz.

File metadata

  • Download URL: trimis_python-1.0.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for trimis_python-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b793792e0065d3e62d4c060cf355b2cf54013339ad125134a50286db6bc2c554
MD5 7ff5a695307b356400c49ed3556f2b36
BLAKE2b-256 2d8f31a83d28c51adc9ea3fd0fdcadb0e41f86d2b6043b4f7cca40769cc711fd

See more details on using hashes here.

File details

Details for the file trimis_python-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: trimis_python-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for trimis_python-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e29e48e3fd70ecdb1ff3d3834a55166f66e274bcd0b6cb8d4ec38ffc0eaab6c6
MD5 a80b5708982c10743200639a855f5d8f
BLAKE2b-256 cc3f7ccafb7d6106bb55cab57685451c35ed23eb8c2d0c9a15f43f3c6153cd96

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