Python
Official Python SDK for the Zernio API. Install zernio-sdk and publish to 14+ social platforms with sync and async clients.
The official Python SDK for the Zernio API, with both synchronous and asynchronous clients.
- Package:
zernio-sdkon PyPI - Source: github.com/zernio-dev/zernio-python
Install
pip install zernio-sdkQuick start
from zernio import Zernio
# Reads ZERNIO_API_KEY from environment (or pass explicitly)
client = Zernio()
# Publish to multiple platforms with one call
post = client.posts.create(
content="Hello world from Zernio!",
platforms=[
{"platform": "twitter", "accountId": "acc_xxx"},
{"platform": "linkedin", "accountId": "acc_yyy"},
{"platform": "instagram", "accountId": "acc_zzz"},
],
publish_now=True,
)
print(f"Published to {len(post.post.platforms)} platforms!")Get your API key from the dashboard, or see Getting started for the full setup walkthrough.
Configuration
client = Zernio(
api_key="your-api-key", # Or set ZERNIO_API_KEY env var
base_url="https://zernio.com/api", # Optional, this is the default
timeout=30.0, # Optional, request timeout in seconds
)Examples
Schedule a post
post = client.posts.create(
content="This post will go live tomorrow at 10am",
platforms=[{"platform": "instagram", "accountId": "acc_xxx"}],
scheduled_for="2025-02-01T10:00:00Z",
)Platform-specific content
Customize content per platform while posting to all at once:
post = client.posts.create(
content="Default content",
platforms=[
{
"platform": "twitter",
"accountId": "acc_twitter",
"customContent": "Short & punchy for X",
},
{
"platform": "linkedin",
"accountId": "acc_linkedin",
"customContent": "Professional tone for LinkedIn with more detail.",
},
],
publish_now=True,
)Upload media
The Python SDK can upload files directly, no presigned URL dance needed:
# Option 1: Direct upload from a file path (simplest)
result = client.media.upload("path/to/video.mp4")
media_url = str(result.files[0].url)
# Option 2: Upload from bytes (max 4MB)
result = client.media.upload_bytes(video_bytes, "video.mp4", mime_type="video/mp4")
media_url = str(result.files[0].url)
# Create post with media
post = client.posts.create(
content="Check out this video!",
media_items=[{"url": media_url, "type": "video"}],
platforms=[
{"platform": "tiktok", "accountId": "acc_xxx"},
{
"platform": "youtube",
"accountId": "acc_yyy",
"platformSpecificData": {"title": "My Video"},
},
],
publish_now=True,
)See the media uploads guide for size limits and per-platform requirements.
List connected accounts
data = client.accounts.list()
for account in data.accounts:
print(f"{account.platform}: @{account.username}")Async support
Every method has an async variant (prefixed with a), and the client works as an async context manager:
import asyncio
from zernio import Zernio
async def main():
async with Zernio(api_key="your-api-key") as client:
posts = await client.posts.alist(status="scheduled")
print(f"Found {len(posts.posts)} scheduled posts")
asyncio.run(main())Error handling
from zernio import Zernio, ZernioAPIError, ZernioRateLimitError, ZernioValidationError
client = Zernio(api_key="your-api-key")
try:
client.posts.create(content="Hello!", platforms=[...])
except ZernioRateLimitError as e:
print(f"Rate limited: {e}")
except ZernioValidationError as e:
print(f"Invalid request: {e}")
except ZernioAPIError as e:
print(f"API error: {e}")See the error handling guide for the API's error codes and retry semantics.
Migrating from Late
All old names continue to work. No code changes are required:
# Old style (still works)
from late import Late, LateAPIError
client = Late(api_key="...")
# New style
from zernio import Zernio, ZernioAPIError
client = Zernio() # reads ZERNIO_API_KEY env varBoth from zernio import ... and from late import ... work identically. The LATE_API_KEY environment variable is also still supported as a fallback when ZERNIO_API_KEY is not set.
Full reference
The SDK exposes every API namespace: posts, accounts, profiles, analytics, queue, media, webhooks, messages, comments, broadcasts, ads, phone_numbers, whatsapp, workflows, and more. Each method maps 1:1 to an API Reference operation.