You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nycex 009769d6c9
make Thumbnails fields public
7 months ago
examples make Thumbnails fields public 7 months ago
src make Thumbnails fields public 7 months ago
.gitignore initial commit 2 years ago
Cargo.toml make Thumbnails fields public 7 months ago
LICENSE initial commit 2 years ago
README.md add example for the playlist to examples/ 8 months ago
logo.png add logo for gitlab 2 years ago
rustfmt.toml add rustfmt.toml file 2 years ago

README.md

yt-api

Crates.io Documentation

about

With yt-api you can interact asynchronously with the youtube-api. Currently it implements the following endpoints:

  • search
  • playlists

example

A basic search request with yt-api:

/// prints the first answer of a search query
fn main() -> Result<(), Error> {
    futures::executor::block_on(async {
        // take api key from enviroment variable
        let key = ApiKey::new(&env::var("YT_API_KEY").expect("YT_API_KEY env-var not found"));

        // create the SearchList struct for the query "rust lang"
        let result = SearchList::new(key)
            .q("rust lang")
            .item_type(ItemType::Video)
            .await?;

        // outputs the title of the first search result
        println!(
            "Title: \"{}\"",
            result.items[0].snippet.title.as_ref().unwrap()
        );
        // outputs the video id of the first search result
        println!(
            "https://youtube.com/watch?v={}",
            result.items[0].id.video_id.as_ref().unwrap()
        );

        Ok(())
    })
}

More examples can be found here.

supported rust versions

the minimum rust version for yt-api is 1.39

license

This project is licensed under the MIT license.

contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in yt-api by you, shall be licensed as MIT, without any additional terms or conditions.