Welcome to the "How to get the latest video from a channel via YouTube API" template guide. This template is designed to help you create a FastAPI-based application that retrieves the latest video details from a YouTube channel. You'll be able to get the video ID, title, and description by providing a channel ID or URL. This guide will walk you through the steps to use this template on the Lazy platform.
To begin using this template, click on the "Start with this Template" button. This will pre-populate the code in the Lazy Builder interface, so you won't need to copy, paste, or delete any code manually.
Before you can use this template, you'll need to set up an environment secret for the YouTube API key. Here's how to obtain and set up your YouTube API key:
Once you have set up your YouTube API key in the environment secrets, press the "Test" button to deploy the app. The Lazy CLI will handle the deployment, and you won't need to worry about installing libraries or setting up your environment.
After pressing the "Test" button and once the app is deployed, the Lazy App's CLI interface will appear. If the code requires user input, you will be prompted to provide it there. For this template, you will need to input the channel ID or URL when prompted by the CLI.
After deployment, Lazy will provide you with a dedicated server link to use the API. You can make requests to the `/latest-video/` endpoint to retrieve the latest video from the specified YouTube channel. Additionally, you will be provided with a link to the FastAPI documentation at `/docs` where you can test the API endpoints directly from your browser.
Here's a sample request you might make to the API:
POST /latest-video/
Content-Type: application/json
{
"channel_id_or_url": "UC_x5XG1OV2P6uZZ5FSM9Ttw"
}
And a sample response you might receive:
{
"video_id": "dQw4w9WgXcQ",
"title": "Rick Astley - Never Gonna Give You Up",
"description": "The official video for “Never Gonna Give You Up” by Rick Astley..."
}
If you wish to integrate this app with an external tool or service, you may need to add the app's server link provided by Lazy to that tool. For example, if you're building a website that displays the latest video from a YouTube channel, you would make an API call to the server link from your website's backend to retrieve the video details.
Remember, this template is designed to work seamlessly on the Lazy platform, so all the heavy lifting of deployment and environment management is taken care of for you. Enjoy building your application!