Listen Notes Podcast API JavaScript Library

2.0.4 · active · verified Wed Apr 22

The `podcast-api` library provides convenient JavaScript bindings for the Listen Notes Podcast API, enabling developers to search, retrieve, and manage podcast and episode metadata programmatically. It supports a wide range of environments, including server-side Node.js applications, serverless Cloudflare Workers/Pages, and client-side browser JavaScript, although browser usage is discouraged without proper API key handling to prevent exposure. The current stable version is 2.0.4, with active development indicated by frequent releases introducing new endpoints like `searchEpisodeTitles` and `fetchPodcastsByDomain`. A key differentiator is its dual client architecture, offering `Client` for Node.js/browser environments and `ClientForWorkers` specifically optimized for Cloudflare Workers, providing streamlined access to the same API that powers the Listen Notes search engine.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart initializes the `podcast-api` client and demonstrates a basic full-text search for podcasts, logging the results. It highlights API key configuration and error handling.

import { Client } from 'podcast-api';

// Initialize the client with your API key.
// For Node.js, use process.env.LISTEN_API_KEY.
// For Cloudflare Workers, use LISTEN_API_KEY from secrets.
// For browser-side, handle key securely (e.g., via a proxy).
const apiKey = process.env.LISTEN_API_KEY ?? 'YOUR_LISTEN_NOTES_API_KEY'; // Replace or ensure env var is set

if (!apiKey || apiKey === 'YOUR_LISTEN_NOTES_API_KEY') {
  console.error('API Key is missing. Please set LISTEN_API_KEY environment variable or replace the placeholder.');
  process.exit(1);
}

const client = Client({ apiKey });

async function searchPodcasts(query) {
  try {
    const response = await client.search({
      q: query,
      sort_by: 'relevance',
      type: 'podcast',
      offset: 0,
      len_min: 10,
      len_max: 30,
      genre_ids: '68,82',
      published_before: 1580172454000,
      published_after: 0,
      only_in: 'title,description',
      language: 'English',
      safe_mode: 0
    });
    console.log(`Found ${response.data.total} podcasts for "${query}":`);
    response.data.results.slice(0, 3).forEach(podcast => {
      console.log(`- ${podcast.title_original} (ID: ${podcast.id})`);
    });
  } catch (error) {
    console.error('Error searching podcasts:', error.message);
  }
}

// Example usage
searchPodcasts('web development');

view raw JSON →