RSS to Social Media: Auto-Post New Feed Items via API
Parse an RSS feed on a schedule and publish each new item to your connected social profiles with PostGate’s API — no third-party RSS-to-social app required.
Auto-post an RSS feed with a small scheduled script: parse the feed with rss-parser, diff item GUIDs against a stored seen list, publish each new item through POST /api/posts with an Idempotency-Key derived from the GUID, then record what was published. Run it on cron, GitHub Actions, or a serverless timer — no database needed.
There is no RSS-to-social app for PostGate, and you don't need one — an RSS feed is just XML you can parse in a few lines of code, and PostGate's POST /api/posts is a plain REST call. This guide wires the two together with a small script: fetch the feed, work out which items are new, and publish each one. Run it however you already run scheduled jobs — cron, GitHub Actions, a serverless function on a timer, or n8n's own Schedule Trigger driving the same logic (see calling PostGate from n8n, Make, and Zapier).
How does the pipeline work end to end?
Four steps, run on a schedule: parse the feed, diff its items against the ones you've already published, publish each new item through PostGate, then record what you just published so the next run doesn't repeat it. Nothing here needs a database — a flat file or a key-value store is enough for most feeds.
Parse the feed with rss-parser
rss-parser is a small, actively maintained npm package that handles RSS 2.0, Atom, and RDF feeds and normalizes them into one item shape with title, link, guid, isoDate, and contentSnippet. Install it with npm install rss-parser.
How do you track what’s already been posted?
Keep a set of seen guid values (falling back to link for feeds without one) in a small JSON file next to the script. Every item not in that set is new. For each one, build the PostGate request body and send it with an Idempotency-Key derived from the item's own GUID — if the job runs twice for any reason, the second attempt returns the first result instead of posting again.
import Parser from 'rss-parser';
import { readFile, writeFile } from 'node:fs/promises';
const FEED_URL = 'https://example.com/feed.xml';
const SEEN_FILE = new URL('./seen-guids.json', import.meta.url);
const PROFILE_GROUP_ID = 'grp_acme123';
const PROFILES = ['pro_x123', 'pro_linkedin456'];
async function main() {
const parser = new Parser();
const feed = await parser.parseURL(FEED_URL);
const seen = new Set(
JSON.parse(await readFile(SEEN_FILE, 'utf8').catch(() => '[]'))
);
const newItems = feed.items.filter((item) => !seen.has(item.guid ?? item.link));
for (const item of newItems.reverse()) {
// oldest first, so posts land in publication order
await publishItem(item);
seen.add(item.guid ?? item.link);
}
await writeFile(SEEN_FILE, JSON.stringify([...seen]));
}
async function publishItem(item) {
const body = `${item.title}\n\n${item.link}`;
const res = await fetch(
`https://postgate.studio/api/posts?profile_group_id=${PROFILE_GROUP_ID}`,
{
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.POSTGATE_API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': `rss-${item.guid ?? item.link}`,
},
body: JSON.stringify({
post: { body },
profiles: PROFILES,
}),
}
);
if (!res.ok) {
console.error(`Failed to publish ${item.link}:`, await res.text());
}
}
main();How do you attach an image when the feed has one?
Not every feed carries media, but when an item includes an enclosure or a Media RSS media:content tag, rss-parser exposes it on item.enclosure.url. Pass that URL straight into media — PostGate fetches and validates public URLs itself, so there's no need to download the image in your script first.
body: JSON.stringify({
post: { body },
profiles: PROFILES,
media: item.enclosure?.url ? [item.enclosure.url] : undefined,
}),Run it on a schedule
A GitHub Actions workflow with a schedule trigger is enough for most blogs — no server to maintain, and secrets stay in the repo's encrypted settings.
name: rss-to-social
on:
schedule:
- cron: '*/15 * * * *'
workflow_dispatch: {}
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20 }
- run: npm install rss-parser
- run: node publish-feed.mjs
env:
POSTGATE_API_KEY: ${{ secrets.POSTGATE_API_KEY }}Prefer no code? Use n8n’s RSS Feed Trigger
n8n ships a built-in RSS Feed Trigger node (its own generic feature, not a PostGate integration) that polls a feed URL and starts a workflow for each new item automatically — no dedupe logic to write. Follow it with an HTTP Request node configured exactly as in the n8n section of our automation-tools guide, and you get the same pipeline without writing or hosting the script above.
Frequently asked questions
How do I stop the script from posting the same RSS item twice?
Keep a set of seen guid values (falling back to link for feeds without one) in a small JSON file next to the script, and send each publish with an Idempotency-Key derived from the item's own GUID. If the job runs twice for any reason, the second attempt returns the first result instead of posting again.
Do I need a database for an RSS-to-social pipeline?
No — nothing in the pipeline needs a database. A flat file or a key-value store is enough for most feeds: the script only has to remember which item GUIDs it has already published between runs.
How do I include the feed item's image in the social post?
When an item includes an enclosure or a Media RSS media:content tag, rss-parser exposes it on item.enclosure.url. Pass that URL straight into the media array — PostGate fetches and validates public URLs itself, so there is no need to download the image in your script first.
Can I auto-post an RSS feed to social media without writing code?
Yes — n8n ships a built-in RSS Feed Trigger node that polls a feed URL and starts a workflow for each new item automatically, with no dedupe logic to write. Follow it with an HTTP Request node configured the same way as the script's request and you get the same pipeline without hosting anything yourself.
What feed formats does rss-parser handle?
rss-parser is a small, actively maintained npm package that handles RSS 2.0, Atom, and RDF feeds, normalizing them into one item shape with title, link, guid, isoDate, and contentSnippet — so the same script works regardless of which flavor the source publishes.
