DEV Community

Cover image for Automate Social Media With Python and the Zernio API
Kevin Meneses González
Kevin Meneses González

Posted on • Originally published at Medium

Automate Social Media With Python and the Zernio API

Most people think growing on social media is about better content.

It's not. It's about showing up. Every day. Without missing a beat.

The accounts that win aren't the ones with the smartest takes. They're the ones that posted while everyone else "didn't have time today."

So the real question isn't what do I post?

It's how do I post consistently without it eating my week?

If you're:

  • a developer building in public,
  • a founder running content for a SaaS,
  • or anyone tired of copy-pasting the same post across five tabs,

this is for you.

The problem isn't ideas. It's friction.

Here's what consistent posting actually looks like when you do it by hand.

You write a tweet. You open Reddit, reformat it, pick a subreddit, post. You open LinkedIn, rewrite the tone, post. You remember you wanted to schedule it for tomorrow morning instead, so you don't post — you set a reminder. The reminder fires while you're in a meeting. You skip it.

Multiply that by every day, across every platform.

This is why most people quit. Not because they ran out of things to say. Because the distribution is exhausting.

And if you're a developer thinking "I'll just script it," you hit a second wall fast: every platform has its own API, its own OAuth dance, its own rate limits, its own media specs. Twitter's API works nothing like Reddit's, which works nothing like LinkedIn's.

You wanted to automate posting. Instead you signed up to maintain five integrations forever.

The reframe

You don't have a content problem. You have a plumbing problem.

The fix isn't more discipline. It's removing the manual step entirely — generate the content, schedule it once, and let an API fan it out across every platform.

Two pieces make that possible:

  • A language model to write fresh posts so you're not recycling the same three lines.
  • One API that speaks to every platform, so your code doesn't care whether it's posting to Twitter or Reddit.

For the first, GPT-4o-mini is cheap and good enough. For the second, I use Zernio.

Why Zernio

Zernio is a unified REST API for social media publishing. One endpoint replaces the 15 separate integrations you'd otherwise build and babysit.

Pros

  • One Bearer token, one JSON payload — posts to Twitter/X, Reddit, LinkedIn, Instagram, Facebook and 10+ more platforms.
  • Schedule, publish now, or bulk-upload — the scheduling logic is built in, not something you write.
  • No SDK. It's plain REST, so Python's requests library is all you need.
  • Free first 2 connected accounts, no credit card — enough to ship this whole project for free.

Cons

  • Pay-per-account after the free tier (graduated: cheaper as you scale).
  • One account per platform per profile, so multi-client agencies need multiple profiles.

Best for: developers who want to add scheduling and cross-posting to a script or product without becoming a full-time API maintenance engineer.

That last point is the whole pitch. You're not paying for a feature you couldn't build. You're paying to never touch five OAuth flows again.

👉 You can grab a free Zernio key here: zernio.link/kevin-meneses

Building the automation

Here's the plan: a script that generates AI posts and schedules four of them across the coming week — two to Twitter, two to Reddit — in a single run.

Set it up once. Run it Monday. Forget about it.

The full project lives on GitHub if you'd rather clone and run it directly:

git clone https://github.com/Kevinelectronics/social-media-automation.git
cd social-media-automation
Enter fullscreen mode Exit fullscreen mode

1. Install and configure

pip install requests python-dotenv openai
Enter fullscreen mode Exit fullscreen mode

Create a .env file with two keys:

ZERNIO_API_KEY=your_zernio_api_key_here
OPENAI_API_KEY=your_openai_api_key_here
Enter fullscreen mode Exit fullscreen mode

Get the Zernio key free at zernio.link/kevin-meneses, and the OpenAI key at platform.openai.com/api-keys. Then log in to Zernio, open Accounts, and connect your Twitter and Reddit profiles.

2. Set up the clients

import os
import json
import random
import requests
from datetime import datetime, timedelta
from openai import OpenAI
from dotenv import load_dotenv

load_dotenv()

client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))

ZERNIO_BASE = "https://zernio.com/api/v1"
HEADERS = {
    "Authorization": f"Bearer {os.getenv('ZERNIO_API_KEY')}",
    "Content-Type": "application/json",
}

TOPICS = [
    "Python automation tips",
    "productivity for developers",
    "shipping side projects",
]
Enter fullscreen mode Exit fullscreen mode

3. Fetch your connected accounts

Zernio gives each connected profile an ID. You need those IDs to tell the API where to post.

def get_accounts():
    r = requests.get(f"{ZERNIO_BASE}/accounts", headers=HEADERS)
    r.raise_for_status()
    return {a["platform"]: a["id"] for a in r.json()}
Enter fullscreen mode Exit fullscreen mode

This returns a clean map:

reddit   → 6a2135f22b2567671ac3e5e4
twitter  → 6a2136552b2567671ac3e855
Enter fullscreen mode Exit fullscreen mode

4. Generate the content

One function for tweets, one for Reddit posts. The Reddit one asks GPT for structured JSON so we get a clean title and body.

def generate_tweet(topic):
    resp = client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[{
            "role": "user",
            "content": f"Write one punchy tweet about {topic}. "
                       f"Max 280 characters. One emoji max, no hashtag spam.",
        }],
    )
    return resp.choices[0].message.content.strip()


def generate_reddit_post(topic):
    resp = client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[{
            "role": "user",
            "content": f"Write a Reddit post about {topic}. "
                       f"Return JSON with keys 'title' and 'body'. No markdown.",
        }],
        response_format={"type": "json_object"},
    )
    return json.loads(resp.choices[0].message.content)
Enter fullscreen mode Exit fullscreen mode

5. Schedule a single post

This is the core call. One payload shape, regardless of platform.

def schedule_post(content, platform, account_id, when, subreddit=None):
    payload = {
        "content": content,
        "platforms": [{"platform": platform, "accountId": account_id}],
        "publishNow": False,
        "scheduledFor": when,
        "timezone": "America/New_York",
    }
    if subreddit:
        payload["platforms"][0]["subreddit"] = subreddit

    r = requests.post(f"{ZERNIO_BASE}/posts", headers=HEADERS, json=payload)
    r.raise_for_status()
    return r.json()["id"]
Enter fullscreen mode Exit fullscreen mode

That's the entire integration. No OAuth handling in your code, no per-platform branching beyond a subreddit field. Zernio normalizes the rest.

6. Schedule the whole week

Loop through four slots, spaced across seven days, alternating platforms.

def schedule_week(accounts):
    start = datetime.now()
    plan = [("twitter", 0), ("reddit", 2), ("twitter", 4), ("reddit", 6)]

    for platform, day_offset in plan:
        when = (start + timedelta(days=day_offset)).replace(
            hour=10, minute=0, second=0, microsecond=0
        ).isoformat()
        topic = random.choice(TOPICS)

        if platform == "twitter":
            content = generate_tweet(topic)
            post_id = schedule_post(content, "twitter", accounts["twitter"], when)
        else:
            post = generate_reddit_post(topic)
            content = f"{post['title']}\n\n{post['body']}"
            post_id = schedule_post(
                content, "reddit", accounts["reddit"], when, subreddit="learnprogramming"
            )

        print(f"{platform:8} | {when} | ID: {post_id}")


if __name__ == "__main__":
    print("🔗 Connecting to Zernio...")
    accounts = get_accounts()
    print("🤖 Generating content and scheduling posts...\n")
    schedule_week(accounts)
    print("\n🎉 Done. Check your Zernio dashboard.")
Enter fullscreen mode Exit fullscreen mode

Run it:

python main.py
Enter fullscreen mode Exit fullscreen mode

And the output:

🔗 Connecting to Zernio...
🤖 Generating content and scheduling posts...

  ✅ twitter  | 2025-06-04T10:00:00 | ID: 6a2142f2d786bdfc96598f5b
  ✅ reddit   | 2025-06-06T10:00:00 | ID: 6a2143aad786bdfc96598f6c
  ✅ twitter  | 2025-06-08T10:00:00 | ID: 6a2144bbd786bdfc96598f7d
  ✅ reddit   | 2025-06-10T10:00:00 | ID: 6a2145ccd786bdfc96598f8e

🎉 Done. Check your Zernio dashboard.
Enter fullscreen mode Exit fullscreen mode

Four posts. A full week. One command.

Make it yours

The script is a skeleton on purpose. Three things to change:

Topics. Edit the TOPICS list to your niche. Trading, design, devops, parenting — whatever you actually post about.

Frequency. The plan list controls how many posts go out and when. Add slots, change the hours, push it to daily.

Platforms. Zernio handles LinkedIn, Instagram and Facebook too. Add a line to the plan with "linkedin" and the matching account ID, and the same schedule_post function just works — no new integration.

From this base you can build:

  • a content calendar that refills itself every Sunday,
  • a product that lets your users schedule across platforms,
  • a cron job on a cheap VPS that runs the whole thing while you sleep.

Key takeaways

  • Consistency beats brilliance on social media, and consistency is automatable.
  • The hard part of automation isn't AI content — it's cross-platform plumbing.
  • One unified API removes that plumbing, so a complete scheduler fits in ~80 lines of Python.

You don't need a marketing team. You need a script and an API that does the boring part.

The complete, runnable code is on GitHub: github.com/Kevinelectronics/social-media-automation.

Get the Zernio API key

To run this, you'll need a Zernio account. The free tier covers your first 2 connected accounts with full API access and no credit card — enough to ship this entire project for free.

👉 Get your free Zernio key here

Connect Twitter and Reddit, drop in your keys, and you'll have a week of posts scheduled before your coffee's cold.

FAQs

❓ Is there a free social media posting API?
✅ Yes. Zernio's free tier includes your first 2 connected accounts with unlimited posts and full REST API access, no credit card required. That's enough to build and run this Python automation end to end.

❓ Can I schedule posts to multiple platforms with one API call?
✅ Yes. Zernio accepts a platforms array in a single request, so one call can target Twitter, Reddit, LinkedIn and more at once. You send one JSON payload and it handles each platform's formatting.

❓ Do I need an SDK to use Zernio with Python?
✅ No. Zernio is a plain REST API with Bearer authentication, so Python's built-in-feel requests library is all you need. No vendor SDK to install or keep updated.

❓ Which platforms does Zernio support?
✅ Twitter/X, Reddit, LinkedIn, Instagram, Facebook, and around ten more including YouTube, TikTok, Threads, Pinterest and Bluesky — all through the same endpoint.


Looking for technical content for your company? I can help — LinkedIn · kevinmenesesgonzalez@gmail.com

Top comments (0)