Search
Search videos by keyword
This guide demonstrates how to use the YouTube Data API to search for videos using a specific keyword.
API Endpoint
Example Usage
To search for videos about “cats”, you can make the following API call:
index.ts
Response
The API will return a JSON object containing an array of video items. Each item includes:
videoId
: The unique identifier for the videotitle
: The title of the videodescription
: A brief description of the videothumbnails
: Various thumbnail images for the videochannelTitle
: The title of the channel that uploaded the video
For a complete list of returned fields, please refer to the API documentation.
Error Handling
If the API call fails, it will return an appropriate HTTP status code along with an error message in the response body. Common errors include:
- 400 Bad Request: Invalid query parameters
- 403 Forbidden: Token is missing or invalid
Always handle potential errors in your code to ensure a smooth user experience.