The search endpoint allows you to find podcasts based on keywords. This is the most basic way to discover podcasts in the database.
The search algorithm looks for matches in:
- Podcast titles
- Podcast descriptions
- Episode titles and descriptions
- Host and guest names
Basic Search Request
Search for podcasts with a simple query
const options = {
method: "GET",
headers: {
"Content-Type": "application/json",
"Authorization": "YOUR_API_TOKEN"
}
};
const query = "technology";
const limit = 20;
const response = await fetch(
`http://localhost:4000/api/v1/podcasts/search?q=${query}&limit=${limit}`,
options
);
const data = await response.json();
console.log(`Found ${data.results.length} podcasts`); Notes
- The search is case-insensitive
- Results are returned in order of relevance by default
- The default limit is 20 results if not specified
For more precise results, you can combine multiple search parameters. This allows you to filter by category, language, and sort order.
Available filters:
- category: Filter by podcast category (technology, business, comedy, etc.)
- language: ISO 639-1 language code (en, es, fr, etc.)
- sortBy: Order results by relevance, popularity, or recency
- minEpisodes: Only show podcasts with at least N episodes
- activeOnly: Only show currently active podcasts
Advanced Search with Filters
Combine multiple parameters for precise results
const searchParams = new URLSearchParams({
q: "artificial intelligence",
limit: "50",
offset: "0",
category: "technology",
language: "en",
sortBy: "relevance"
});
const options = {
method: "GET",
headers: {
"Content-Type": "application/json",
"Authorization": "YOUR_API_TOKEN"
}
};
const response = await fetch(
`http://localhost:4000/api/v1/podcasts/search?${searchParams}`,
options
);
const data = await response.json(); Warning
- Some filters may significantly reduce the number of results
- Invalid category or language codes will be ignored
When dealing with searches that return many results, you'll need to implement pagination. The API supports offset-based pagination with a maximum limit of 100 results per request.
Best practices for pagination:
- Use a reasonable limit (50-100) per request
- Implement proper error handling for network failures
- Add delays between requests to avoid rate limiting
- Track total results to know when to stop paginating
Paginated Search Implementation
Retrieve all search results with automatic pagination
async function getAllSearchResults(query, maxResults = 1000) {
const results = [];
let offset = 0;
const limit = 100;
while (results.length < maxResults) {
const searchParams = new URLSearchParams({
q: query,
limit: limit.toString(),
offset: offset.toString()
});
const response = await fetch(
`http://localhost:4000/api/v1/podcasts/search?${searchParams}`,
options
);
const data = await response.json();
if (data.results.length === 0) {
break; // No more results
}
results.push(...data.results);
offset += limit;
// Optional: Add delay to avoid rate limiting
await new Promise(resolve => setTimeout(resolve, 100));
}
return results;
}
const allPodcasts = await getAllSearchResults("business", 500);
console.log(`Retrieved ${allPodcasts.length} total podcasts`); Warning
- Be mindful of rate limits when making many requests
- Large result sets may take significant time to retrieve
- Always implement proper error handling for network issues
Notes
- The maximum limit per request is 100
- Consider implementing a progress indicator for large result sets
- Cache results locally to avoid repeated API calls