yt-api

Crates.io Documentation dependency status pipeline status

about

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

example

A basic search request with yt-api:

``` rust /// prints the first answer of a search query fn main() { // take api key from enviroment variable let key = ApiKey::new(&env::var("YTAPIKEY").expect("YTAPIKEY env-var not found"));

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

let future = async move {
    // perform the search
    let result = search_list.perform().await.unwrap();
    // 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()
    );
};

// run the future
tokio::run(future.unit_error().boxed().compat());

} ```

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.