This is a draft preview and is not publicly visible.
Productivity & Tools

How to Automate Social Media Posts with Python and the Publora API

29 views
Serge Bulaev
Serge Bulaev
How to Automate Social Media Posts with Python and the Publora API

TL;DR

A working Python guide to automating social media: connect accounts, post to 10 platforms, schedule with one script, and attach media - using the Publora API.

If you post to more than one social account, doing it by hand is a tax on your week. This guide shows the Python version of taking that off your plate: connect your accounts once, then publish and schedule to all 10 networks from a single script. No per-platform OAuth, no ten separate SDKs — one API. The full endpoint reference is at docs.publora.com; below is the working code.

Setup

You need Python, the requests library, and a Publora API key (grab one in the dashboard under API → Generate API Key — it's free on the Starter plan). Connecting your social accounts is a one-time OAuth step in the dashboard; after that, the API posts to them.

pip install requests
import requests from datetime import datetime, timedelta, timezone API_KEY = "YOUR_API_KEY" BASE = "https://api.publora.com/api/v1" headers = {"Content-Type": "application/json", "x-publora-key": API_KEY}

Step 1: List Your Connected Accounts

Every post targets accounts by their platformId. Pull the list first:

def get_connections(): r = requests.get(f"{BASE}/platform-connections", headers=headers) return r.json()["connections"] for c in get_connections(): print(c["platformId"], "-", c["displayName"]) # twitter-123456 - My Account # linkedin-ABC123 - John Doe

Step 2: Publish to Several Platforms in One Call

A post is a content string plus a list of platforms. Send it and you get back a postGroupId you can use later to reschedule, attach media, or delete.

def create_post(content, platforms, scheduled_time=None): body = {"content": content, "platforms": platforms} if scheduled_time: body["scheduledTime"] = scheduled_time r = requests.post(f"{BASE}/create-post", headers=headers, json=body) r.raise_for_status() return r.json() result = create_post( "Shipping our new feature today.", ["twitter-123456", "linkedin-ABC123", "bluesky-abc789"], ) print(result["postGroupId"]) # 507f1f77bcf86cd799439011

One thing to know: if you omit a scheduled time, the post is created as a draft rather than published. That's exactly what you want before attaching media (more on that below). Include a time and it goes into the queue.

Step 3: Schedule for a Specific Time

Scheduling is one field: scheduledTime in ISO 8601 UTC. The scheduler checks for due posts every minute, so it publishes within about 60 seconds of the time you set.

create_post( "Weekly tips thread goes live now.", ["linkedin-ABC123", "twitter-123456"], scheduled_time="2026-07-01T14:30:00.000Z", )

The gotcha that bites people: that time is UTC. Convert from your own zone before you queue, or your posts land hours early. In Python:

from datetime import datetime, timezone # 9:00 AM on 2026-07-01 in UTC when = datetime(2026, 7, 1, 9, 0, tzinfo=timezone.utc) scheduled = when.strftime("%Y-%m-%dT%H:%M:%S.000Z")
One Python script sends a single request that publishes to all 10 Publora platforms

Step 4: Schedule a Whole Week in One Loop

This is where automation earns its keep. Keep your posts in a list (or read them from a CSV or your database) and queue a week with a loop:

posts = [ "Monday: the one metric we stopped ignoring.", "Tuesday: a mistake that cost us two weeks.", "Wednesday: the workflow we actually use.", "Thursday: a question we keep getting.", "Friday: what shipped this week.", ] channels = ["linkedin-ABC123", "twitter-123456"] start = datetime(2026, 7, 6, 9, 0, tzinfo=timezone.utc) # Mon 9:00 UTC for i, text in enumerate(posts): when = (start + timedelta(days=i)).strftime("%Y-%m-%dT%H:%M:%S.000Z") create_post(text, channels, scheduled_time=when) print("queued", when)

Sit down once, run it, and your week publishes itself.

Attaching Images and Video

Media takes a specific order, because the file has to be fully uploaded before the scheduler runs. The flow is draft → upload → schedule:

Four-step Publora media flow: create draft, get upload URL, PUT the file, then update-post to schedule
  1. Create a draft — call create-post with no scheduledTime, keep the postGroupId.
  2. Get an upload URLPOST /get-upload-url with that postGroupId returns a pre-signed S3 URL.
  3. Upload the filePUT the bytes to that URL.
  4. Schedule itPUT /update-post/{postGroupId} with a scheduledTime.

One rule worth remembering: Instagram, TikTok, and YouTube require media on every post — a text-only post to those will be accepted at creation but fail when it publishes. Attach at least one image or video for them.

Plan Limits to Know

  • Starter (free): 15 posts/month total, up to 3 scheduled at once, schedule up to 7 days ahead, all 10 platforms except X.
  • Pro ($2.99/account billed yearly): 100 posts per connected account/month, no schedule horizon, X included.
  • Premium ($5.99/account billed yearly): 500 posts per connected account/month.

Full REST API and MCP access are on every tier, including the free one. And note the API is server-to-server — the key header isn't CORS-allowed, so call it from a backend or script, never from browser JavaScript, and keep your key out of client code.

Prefer to Let an Agent Do It?

If you're working inside an AI agent, you can skip the scripting entirely: Publora ships a first-party MCP server, so Claude, Cursor, or an n8n workflow can schedule posts from a plain-language instruction. See the social media scheduling API guide for the overview and connecting Publora MCP to Claude Code to set it up.

FAQ

How do I post to social media with Python?

Install requests, put your key in the x-publora-key header, and POST to api.publora.com/api/v1/create-post with a content string and a list of platform IDs. One request publishes to every account you list.

How do I schedule a post for later?

Add scheduledTime in ISO 8601 UTC (e.g. 2026-03-15T14:30:00.000Z). Omit it and the post is saved as a draft. The scheduler publishes within about a minute of the set time.

Can I attach images or video from Python?

Yes: create a draft, request an upload URL from get-upload-url, PUT the file, then set scheduledTime via update-post. Instagram, TikTok, and YouTube require media.

Is the API safe to call from the browser?

No — it's server-to-server. The key header isn't CORS-allowed and shouldn't be exposed in client code. Call it from a backend, a script, or a serverless function.

Build against the API free

Full REST and MCP access on the free Starter plan — no credit card. Grab a key and publish to 10 platforms from Python.

Get Started Free

Further Reading


About the author. Written by the Publora team. Code, endpoints, and limits were taken from the live Publora API docs in June 2026; APIs change, so check docs.publora.com for the current reference.

Related Articles