Registry / http-networking / podcast-api

podcast-api

JSON →
library1.1.6jsnpmunverified

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.

npm install podcast-api
INSTALL
IMPORT
SIG · PODCAST-API
P
podcast-api
http-networkingjavascriptv1.1.6
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Client
import { Client } from 'podcast-api'; const client = Client({ apiKey: process.env.LISTEN_API_KEY ?? '' });
const Client = require('podcast-api');
Use named import for ESM. For CommonJS, `require` returns an object with named exports, so destructuring `const { Client } = require('podcast-api');` is correct. Trying to instantiate the entire `require` result directly as `Client` is incorrect.
ClientForWorkers
import { ClientForWorkers } from 'podcast-api'; const client = ClientForWorkers({ apiKey: LISTEN_API_KEY });
const { ClientForWorkers } = require('podcast-api');
This client is specifically designed for Cloudflare Workers and assumes `LISTEN_API_KEY` is available as a secret in the Worker's scope. While a CommonJS `require` might technically work in some build environments for Workers, ESM `import` is the idiomatic and recommended approach for Cloudflare Workers.
Client
const { Client } = require('podcast-api'); const client = Client({ apiKey: process.env.LISTEN_API_KEY ?? '' });
This is the recommended CommonJS pattern for Node.js and browser environments. Ensure `LISTEN_API_KEY` is securely managed via environment variables.

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');
Debug
Known issues
gotchaDirectly using the Podcast API client with an exposed API key in client-side browser JavaScript is strongly discouraged. This can lead to your API key being compromised.
fix
Proxy requests through your own backend server or a serverless function (like Cloudflare Workers) to keep your API key secure.
affects: >=1.0.0
gotchaTwo distinct client classes exist: `Client` for Node.js/browser environments and `ClientForWorkers` for Cloudflare Workers/Pages functions. Using the wrong client can lead to unexpected behavior or errors, especially concerning API key handling.
fix
For Node.js or browser, use `import { Client } from 'podcast-api';`. For Cloudflare Workers, use `import { ClientForWorkers } from 'podcast-api';` and ensure your API key is stored as a Worker secret.
affects: >=2.0.1
gotchaThe library requires Node.js version 10 or higher. Running it on older Node.js versions may result in compatibility issues or runtime errors.
fix
Ensure your Node.js environment is updated to version 10 or newer. Check your `node` version using `node -v`.
affects: <=1.x
Errors
Common errors & fixes
API key is missing
The `apiKey` parameter was not provided during client initialization, or the `process.env.LISTEN_API_KEY` (or `LISTEN_API_KEY` for Workers) environment variable was not set.
fix
Initialize the client with `Client({ apiKey: 'YOUR_API_KEY' })` or ensure your `LISTEN_API_KEY` environment variable is correctly configured and accessible in your application's environment.
TypeError: (0 , podcast_api__WEBPACK_IMPORTED_MODULE_0__.Client) is not a function
This error often occurs in environments using module bundlers or transpilers when a default import is attempted for a library that only provides named exports, or when CommonJS `require` is used and then the result is incorrectly called directly as a function.
fix
Ensure you are using named imports for ESM (`import { Client } from 'podcast-api';`) or destructuring for CommonJS (`const { Client } = require('podcast-api');`). Do not attempt `import Client from 'podcast-api';` or `const Client = require('podcast-api'); Client(...)`.
Upgrade
Version history
1.1.6latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
podcast-api — npm install podcast-api · libregistry