Export RSS from Sanity for Apple Podcasts

4 replies
Last updated: Jun 7, 2020
Is it possible to export RSS from Sanity to use in Apple podcasts?
AI Update

Yes, it's definitely possible to export RSS from Sanity to use in Apple Podcasts! Based on the podcasting guide and Sanity's capabilities, here's what you need to know:

How to Generate a Podcast RSS Feed from Sanity

The basic approach involves creating an API endpoint that queries your Sanity content and generates an RSS feed in the format Apple Podcasts expects. Here's the workflow:

  1. Set up your podcast schema - You can use the sanity-plugin-podcast which provides a ready-made schema for podcasts, episodes, and all the metadata Apple Podcasts requires.

  2. Create an RSS endpoint - In your Next.js app (or whichever framework you're using), create an API route that:

    • Queries Sanity for your podcast and episode data using GROQ
    • Formats the data into valid RSS XML following the iTunes podcast namespace specifications
    • Returns the XML with proper content-type headers
  3. Query for audio file URLs - When fetching episode data, you'll want to project the file asset fields to get the actual URLs:

*[_type == "episode"] {
  ...,
  file {
    "url": asset->url,
    "mimeType": asset->mimeType,
    "size": asset->size
  },
  coverArt {
    "url": asset->url
  }
}

Important Technical Considerations

Audio File Hosting: Sanity's CDN (cdn.sanity.io) does support HTTP range requests (byte-range requests), which is crucial for podcast players. This allows listeners to seek within episodes and enables progressive download - both important features for podcast distribution.

File Asset Metadata: The Sanity file asset type automatically tracks important metadata like mimeType and size, which you'll need to include in your RSS feed's <enclosure> tags for Apple Podcasts compatibility.

RSS Requirements: Your RSS feed needs to include:

  • iTunes-specific tags (category, explicit rating, author, etc.)
  • Episode enclosures with proper url, length (file size in bytes), and type (MIME type)
  • Proper GUID for each episode
  • Publication dates

Modern Approach with Sanity Functions

For a more robust solution, consider using Sanity Functions to automatically regenerate your RSS feed when content changes. You could set up an event handler that triggers whenever an episode is published, ensuring your RSS feed is always up-to-date without manual rebuilding.

The podcasting guide walks through building a complete podcast web app with Sanity Studio, and you'd extend that by adding an RSS generation endpoint. The same GROQ queries that power your website can power your RSS feed, keeping everything in sync.

Show original thread
4 replies
Thank you 🙂
Here using serverless on Netlify https://github.com/sanity-io/Syntax
Thank you Knut 🙂

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?