Skip to main content

Official SendCraft SDK for Python - Send transactional emails and campaigns via the SendCraft API

Project description

SendCraft Python SDK

Official Python SDK for SendCraft — send transactional emails and campaigns via the SendCraft API.

Installation

pip install sendcraft-sdk

Quick Start

import os
from sendcraft import SendCraft

client = SendCraft(api_key=os.environ["SENDCRAFT_API_KEY"])

result = client.send_email(
    to_email="user@example.com",
    subject="Hello from SendCraft",
    html_content="<h1>Hello!</h1><p>Welcome!</p>",
    from_email="noreply@yourdomain.com"
)

print(result)

Environment Variables

SENDCRAFT_API_KEY=sk_live_your_key_here

Usage Examples

Send Bulk Emails

client.send_bulk_emails(
    emails=[
        {"toEmail": "user1@example.com", "toName": "John"},
        {"toEmail": "user2@example.com", "toName": "Jane"},
    ],
    subject="Weekly Newsletter",
    html_content="<h1>This week...</h1>",
    from_email="newsletter@yourdomain.com"
)

Create Campaign

client.create_campaign(
    name="Product Launch",
    subject="Big News!",
    html_content="<h1>Check it out!</h1>",
    from_email="marketing@yourdomain.com",
    recipients=["user1@example.com", "user2@example.com"]
)

Error Handling

from sendcraft import SendCraft, SendCraftError, UnauthorizedError, RateLimitError

try:
    client.send_email(...)
except UnauthorizedError:
    print("Invalid API key")
except RateLimitError:
    print("Too many requests")
except SendCraftError as e:
    print("Error:", e)

API Reference

Method Description
send_email(...) Send a single email
send_bulk_emails(...) Send to multiple recipients
schedule_email(...) Schedule email for later
get_email_stats() Get email statistics
create_campaign(...) Create campaign
get_campaigns(limit) List campaigns
send_campaign(id) Send campaign
create_template(...) Create template
get_templates() List templates
create_webhook(...) Create webhook
get_analytics(id) Campaign analytics
get_account() Account info

Support

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

sendcraft_sdk-1.0.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

sendcraft_sdk-1.0.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for sendcraft_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 90b7ee6a330a86523b386aa927bf32185f0049a24c416751103f5a81847ad44e
MD5 57586470a170613a850f928b24460447
BLAKE2b-256 8d8d14b28c924cb93360aa4d03703fe71694b5fff1116f46ca5294d63acd02df

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for sendcraft_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b816ff65f7361028d95059dd4623e450d1f63a5c3436a4b31ec28dbe02e9821
MD5 f243134bfac2638e9cd29e25a71fc07e
BLAKE2b-256 8b9856cf9870c09c756bc4815500977cbd65dc51cc3879c4d64e8eb5f2c09cae

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