Follow new episodes
Watch a list of podcasts and react when they publish.
There are no webhooks yet, so following shows means checking them on a schedule. Done right, it costs one or two credits per show per check.
The loop
For each podcast you follow:
POST /podcasts/:id/refresh: re-reads the feed. The response says how manynew_episodesit found.- If
new_episodes> 0,GET /podcasts/:id/episodes?page_size=<new_episodes>returns exactly the new ones, newest first.
import { lookup } from "./lookup" // see "Transcripts end to end"
const following = [8017674, 920666, 1234567]
for (const podcastId of following) {
try {
const { new_episodes } = await lookup<any>(`/podcasts/${podcastId}/refresh`, { method: "POST" })
if (new_episodes === 0) continue
const { episodes } = await lookup<any>(`/podcasts/${podcastId}/episodes?page_size=${Math.min(new_episodes, 100)}`)
for (const episode of episodes) console.log("new:", episode.title, episode.url)
} catch (error: any) {
// refresh_too_soon: someone refreshed it in the last minute, the episodes are already fresh
if (error.code !== "refresh_too_soon") console.error(podcastId, error.code, error.message)
}
}How often?
Most shows publish weekly. Checking every few hours is plenty, and keeps costs low:
| Shows followed | Checks per day | Credits per month (approx.) |
|---|---|---|
| 5 | 4 | 600 + new episodes |
| 20 | 2 | 1,200 + new episodes |
| 100 | 1 | 3,000 + new episodes |
Mind the per-minute limit
On Free, 10 calls per minute means pausing between podcasts when you follow many. On Pro the limit is 600.
Cheaper alternative for many shows
Search with updated_within=30d and sort=recent shows which podcasts published recently, 24 at a time, refreshed daily for every show. Use it to decide which shows to refresh, instead of refreshing all of them.