Skip to content

Python + REST API

Schedule social media posts with Python

Python does not need a special integration layer here. Use requests, httpx or your existing HTTP client to talk to PostSider from a script, worker or backend.

Start with a working REST example, or explore the API and product use cases.

How it works

Treat social publishing like any other backend API call.

Your Python code owns the trigger and business logic. PostSider keeps the social account connections and publishing state out of your application.

01

Keep the API key server-side

Load the PostSider credential from an environment variable in your script, worker, Django service or FastAPI application.

02

Fetch the connected destinations

Call the integrations endpoint and choose the account your Python job should publish to.

03

Create the publishing request

Send the content and target integration to the public API, adding a future UTC timestamp when the post should be scheduled.

04

Store the result

Keep the returned post ID and read its state later, or consume webhooks when another part of your Python application depends on delivery.

Concrete example

Schedule one X post from Python and read it back

There is no Python-specific SDK, and you do not need one: requests covers the whole flow. Resolve the channel, save the payload and key, create, then read the returned ID. Swap the settings block for another provider's fields from the API reference, and run it from cron, Celery or a scheduled function.

import os, uuid, requests

BASE = "https://api.postsider.com/public/v1"
HEADERS = {"Authorization": os.environ["POSTSIDER_API_KEY"]}  # raw key, no "Bearer"

# 1. Resolve the channel ID from the integrations list.
channels = requests.get(f"{BASE}/integrations", headers=HEADERS, timeout=20)
channels.raise_for_status()
x = next(c for c in channels.json() if c["identifier"] == "x" and not c["disabled"])

# 2. Build the payload once and give it a stable idempotency key.
payload = {
    "type": "schedule",                     # draft | schedule | now
    "date": "2026-11-16T14:00:00.000Z",     # future UTC ISO timestamp
    "shortLink": False,
    "tags": [],
    "posts": [{
        "integration": {"id": x["id"]},
        "value": [{"content": "Weekly digest is live. Link in the first comment.", "image": []}],
        "settings": {"__type": "x", "who_can_reply_post": "everyone"},
    }],
}
key = str(uuid.uuid4())                     # reuse on a timeout retry, never regenerate

# 3. Create, then read the exact post back. 2xx means accepted, not published.
created = requests.post(
    f"{BASE}/posts",
    json=payload,
    headers={**HEADERS, "Idempotency-Key": key},
    timeout=30,
)
created.raise_for_status()
post_id = created.json()[0]["postId"]

post = requests.get(f"{BASE}/posts/{post_id}", headers=HEADERS, timeout=20).json()
print(post["posts"][0]["state"], post["posts"][0]["publishDate"])  # QUEUE = scheduled

FAQ

Common questions.

Can I schedule social media posts with Python?
Yes. A Python script or backend can call the PostSider REST API to create drafts, immediate publications or scheduled social posts.
Do I need a Python-specific SDK?
No. Any normal HTTP client works. PostSider also publishes an OpenAPI specification if you prefer generated client tooling.
Can I run it from a cron job?
Yes. Cron jobs, Celery workers, scheduled functions and normal server processes can all call the same API.
Should the API key live in source code?
No. Load it from an environment variable or secret manager so it is not committed to the repository.

Use the same publishing system from code

Connect the channels once. Keep the workflow in your stack.

Call REST directly, use the typed SDK, or expose the same publishing actions to an MCP-compatible agent.