#youtube #api #async #api-key #api-bindings #playlist

deprecated yt-api

a work in progress library to interact asynchronously with the youtube api

9 releases

0.3.2 May 7, 2022
0.3.1 Mar 24, 2021
0.3.0-alpha.1 Oct 20, 2019
0.2.0 Sep 23, 2019
0.1.1 Aug 14, 2019

#45 in #playlist

36 downloads per month

MIT license

280KB
835 lines

This project was mostly developed for fun hasn't been maintained for quite some time. Consider using google_youtube3 which is maintained, now also async and supports much more endpoints than yt-api.

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.

Dependencies

~9–28MB
~383K SLoC