Building the Subspace Bot — Daily Trek, One Post at a Time
A look behind the scenes at how I built a bot to post a random Star Trek episode every day using my Subspace API — plus a few choice words for X's absurd API access policies.
Building the Subspace Bot (and Why X Can Get in the Bin)
Sometimes you build something just because you can.
After launching Subspace — my Star Trek episode API — yesterday, I had a thought: wouldn’t it be neat if it posted a random episode every day to social media? Just a little moment of Trek every afternoon, reminding folks how vast and weird and occasionally brilliant the franchise really is.
So I built it.
The Idea
The core idea was simple:
- At a set time each day, run a script.
- Pull a random episode from the Subspace API.
- Format a short, readable post with the episode title, series, season/episode number, and air date.
- Send that post to various social media sites.
A few small hurdles? Sure. But nothing major.
The Build
The script itself is a lightweight Python job that calls the Subspace API’s /episodes/random
endpoint, formats the result with a nice readable date (none of that 2025-04-30
garbage — give me “30 April 2025” like a civilised person), and pushes it out via the relevant APIs.
Mastodon was first. It has a fairly straightforward API, well-documented and friendly to hobbyists. After generating an access token and picking a Redirect URI (by the way, urn:ietf:wg:oauth:2.0:oob
is just a placeholder when you’re not using a full web-based OAuth flow — in this case, it worked fine), I was up and running pretty quickly.
Bluesky was next. Also quite friendly. App passwords and straightforward endpoints made it easy enough to integrate.
Then There Was X
And this is where things went downhill for a bit.
Once upon a time, you could spin up a bot that posted to Twitter using their API without mortgaging your soul. Those days are long gone. Under the current regime, access to the API is locked behind a paywall — and not a small one. We’re talking US$200 per month if you want the kind of access that would allow even basic posting.
For a small one-post-a-day hobby bot? Ridiculous and completely out of the question.
So I didn’t bother and stripped out the Twitter integration entirely. Deleted the API keys, removed it from the .env
, and moved on. If you’re looking for these posts, you’ll find them where APIs are still friendly: Mastodon and Bluesky.
Running It Automatically
Once the script was working, I set up a daily cron job on my server (running US Pacific time) to trigger at 6PM each evening. Nice and simple:
1
0 18 * * * ~/.venv/bin/python ~/trekbot/post.py >> ~/trekbot/cron.log 2>&1
The result? A daily hit of Star Trek, no manual effort required.
Final Thoughts
This was a fun little side project — small in scope, but surprisingly satisfying. It’s also another great use of the Subspace API, which I built partly as a learning tool and partly to scratch an itch.
As for X? I’ll say it again: get in the bin.