Python SDK for the ByteSend API
Project description
ByteSend Python SDK
A minimal Python SDK for the ByteSend API, mirroring the structure of the JavaScript SDK.
Installation
Install via pip or Poetry:
pip install bytesend
# or
poetry add bytesend
Usage
from bytesend import ByteSend, types
# By default: raises ByteSendHTTPError on non-2xx.
client = ByteSend("bs_123")
# 1) TypedDict payload (autocomplete in IDEs). Use dict to pass 'from'.
payload: types.EmailCreate = {
"to": "test@example.com",
"from": "no-reply@example.com",
"subject": "Hello",
"html": "<strong>Hi!</strong>",
}
resp, _ = client.emails.send(payload=payload)
# 2) Or pass a plain dict (supports 'from')
resp, _ = client.emails.send(payload={
"to": "test@example.com",
"from": "no-reply@example.com",
"subject": "Hello",
"html": "<strong>Hi!</strong>",
})
# Idempotent retries: same payload + same key returns the original response
resp, _ = client.emails.send(
payload=payload,
options={"idempotency_key": "signup-123"},
)
# Works for batch requests as well
resp, _ = client.emails.batch(
payload=[payload],
options={"idempotency_key": "bulk-welcome-1"},
)
# If the same key is reused with a different payload, the API responds with HTTP 409.
# 3) Campaigns
campaign_payload: types.CampaignCreate = {
"name": "Welcome Series",
"subject": "Welcome to our service!",
"html": "<p>Thanks for joining us!</p>",
"from": "welcome@example.com",
"contactBookId": "cb_1234567890",
}
campaign_resp, _ = client.campaigns.create(payload=campaign_payload)
# Schedule a campaign
schedule_payload: types.CampaignSchedule = {
"scheduledAt": "2024-12-01T10:00:00Z",
}
schedule_resp, _ = client.campaigns.schedule(
campaign_id=campaign_resp["id"],
payload=schedule_payload
)
# Pause/resume campaigns
client.campaigns.pause(campaign_id="campaign_123")
client.campaigns.resume(campaign_id="campaign_123")
# Toggle behavior if desired:
# - raise_on_error=False: return (None, error_dict) instead of raising
# No model parsing occurs; methods return plain dicts following the typed shapes.
client = ByteSend("bs_123", raise_on_error=False)
raw, err = client.emails.get(email_id="email_123")
if err:
print("error:", err)
else:
print("ok:", raw)
Webhook Local Example
For a runnable webhook verification demo project, see:
example/webhook-test-project/README.md
Development
This package is managed with Poetry. Models are maintained in-repo under
bytesend/types.py (readable names). Update this file as the API evolves.
It is published as bytesend on PyPI.
Available Resources
- Emails:
client.emails.send(),client.emails.get() - ContactBooks:
client.contact_books.list(),client.contact_books.create(),client.contact_books.get(),client.contact_books.update() - Contacts:
client.contacts.create(),client.contacts.list(),client.contacts.get(),client.contacts.bulk_create(),client.contacts.bulk_delete() - Domains:
client.domains.create(),client.domains.get(),client.domains.verify() - Campaigns:
client.campaigns.create(),client.campaigns.get(),client.campaigns.schedule(),client.campaigns.pause(),client.campaigns.resume()
Notes
- Human-friendly models are available under
bytesend.types(e.g.,EmailCreate,CampaignCreate,Contact,APIError). - Endpoint methods accept TypedDict payloads or plain dicts via the
payload=keyword.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bytesend-0.1.0.tar.gz.
File metadata
- Download URL: bytesend-0.1.0.tar.gz
- Upload date:
- Size: 24.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa60d3dbd65c3ea770cdebae0ed6d0627de80e7562c0f61e5dfd89cba2557503
|
|
| MD5 |
d51ff03efc850faf662ea1bd1a1953e3
|
|
| BLAKE2b-256 |
200ccfeadd3f8aaebac5133c37bdcaf46c2a31667277eca2734e84f77ed05775
|
Provenance
The following attestation bundles were made for bytesend-0.1.0.tar.gz:
Publisher:
pypi-release.yml on NodeByteLTD/ByteSend
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bytesend-0.1.0.tar.gz -
Subject digest:
aa60d3dbd65c3ea770cdebae0ed6d0627de80e7562c0f61e5dfd89cba2557503 - Sigstore transparency entry: 1486483163
- Sigstore integration time:
-
Permalink:
NodeByteLTD/ByteSend@bf645b31c8faa1a7f389b33f985775d3e446128a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/NodeByteLTD
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-release.yml@bf645b31c8faa1a7f389b33f985775d3e446128a -
Trigger Event:
push
-
Statement type:
File details
Details for the file bytesend-0.1.0-py3-none-any.whl.
File metadata
- Download URL: bytesend-0.1.0-py3-none-any.whl
- Upload date:
- Size: 27.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
019663931495318949ea2c1175c3124cf8cb63bf33f5273b6c4cf7fa1ab2be11
|
|
| MD5 |
026ec3ec1f4f3484d2513927a4ee2984
|
|
| BLAKE2b-256 |
b24236858d6f0d903804cc40db5d7f09d9c199eb01e15c82ef41de01f72b6d77
|
Provenance
The following attestation bundles were made for bytesend-0.1.0-py3-none-any.whl:
Publisher:
pypi-release.yml on NodeByteLTD/ByteSend
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bytesend-0.1.0-py3-none-any.whl -
Subject digest:
019663931495318949ea2c1175c3124cf8cb63bf33f5273b6c4cf7fa1ab2be11 - Sigstore transparency entry: 1486483267
- Sigstore integration time:
-
Permalink:
NodeByteLTD/ByteSend@bf645b31c8faa1a7f389b33f985775d3e446128a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/NodeByteLTD
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-release.yml@bf645b31c8faa1a7f389b33f985775d3e446128a -
Trigger Event:
push
-
Statement type: