Overview
The Nadie Sabe Nada podcast application integrates with two primary APIs:- Podcast API: Custom API for fetching podcast episodes and metadata
- YouTube Data API v3: For finding and displaying video versions of podcast episodes
Podcast API
The application uses a custom podcast API hosted on Netlify to fetch all podcast episodes.Base URL
Endpoints
Fetches all podcast episodes with full metadata.Implementation:
src/store/slices/podcastSlice.js:4-7Response Structure:Implementation
The podcast data is fetched using Redux Toolkit’screateAsyncThunk:
podcastSlice.js
State Management
The podcast slice manages the following state:Error Handling
The API integration includes error handling at multiple levels:- Network Errors: Caught by Redux Toolkit’s rejection handler
- Invalid Response: Handled in component level
- Missing Data: Navigates to 404 page
Error Handling Example
YouTube Data API v3
The application uses YouTube’s Data API to find video versions of podcast episodes.Endpoint
Searches for videos on YouTube matching the podcast episode title.Implementation:
src/components/PodcastDetail/PodcastDetail.jsx:193-197src/components/LastPodcast/LastPodcast.jsx:188-192
Request Structure
The application constructs YouTube API requests with the following parameters:Request Example
Query Parameters
The part parameter specifies a comma-separated list of one or more search resource properties.
The search query term. In this case, the podcast episode title (URL-encoded).
Your YouTube Data API key from environment variables (
REACT_APP_YT_API_KEY).Restricts search results to videos from the specified channel (
REACT_APP_CHANNEL_ID).Restricts results to a particular type of resource (video, channel, or playlist).
Maximum number of results to return (1-50). Set to 1 to get only the most relevant video.
Response Structure
YouTube API Response
Video Player Integration
Once a video ID is retrieved, it’s displayed using thereact-youtube component:
YouTube Component
Implementation Details
The YouTube API is called when a podcast detail page loads:Error Handling
Podcast API Errors
Errors from the podcast API are captured in the Redux state:Error State
Component Error Handling
YouTube API Errors
YouTube API errors are handled with try-catch blocks:YouTube Error Handling
If the YouTube API fails, the application gracefully degrades - the audio player continues to function without the video component.
Rate Limiting
YouTube API Quota
- Daily Quota: 10,000 units per day (default)
- Search Cost: 100 units per request
- Requests per Day: ~100 searches per day
Optimization Strategies
- Cache video IDs: Store video IDs in localStorage to reduce API calls
- Lazy loading: Only fetch videos when the detail page is viewed
- Conditional loading: Check if video ID exists before making API call
Testing API Integration
You can test the APIs directly:Dependencies
The following packages are used for API integration:- axios (
^1.7.7): HTTP client for podcast API requests - react-youtube (
^10.1.0): YouTube player component - @reduxjs/toolkit (
^2.2.1): State management and async thunks
Best Practices
- Always encode URLs: Use
encodeURIComponent()for search queries - Handle errors gracefully: Don’t crash the app if APIs fail
- Show loading states: Provide feedback while fetching data
- Implement retry logic: For transient network errors
- Cache responses: Reduce unnecessary API calls
