Skip to content

Zenithsiz/twitch-helix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Twitch Helix API

This library provides a rust API to interact with the twitch Helix API, as described here.

The API is focused around describing each request, with the actual requests being done either outside the crate, or by the Client type.

Example

The following example shows how to use the library to make a request to validate an oauth token, receiving a client id and then to query a stream's info, using tokio.

use twitch_helix::{Client, OAuthRequest, HelixRequest};

#[tokio::main]
pub async fn main() -> Result<(), Box<dyn std::error::Error>> {
	let oauth_token = "<insert your oauth token>";
	let mut client = Client::new(oauth_token);
	let validation = client
		.request_oauth(&twitch_helix::request::oauth::validate::Request)
		.await?
		.into_result()?;
	
	let channel = "<insert the channel name here>";
	let channel_info_request = twitch_helix::request::search::channel::Request::new(channel);
	let channel_info_response = client
		.request_helix(&channel_info_request, &validation.client_id)
		.await?
		.into_result()?
		.data;
	let channel_info = channel_info_request.channel(channel_info_response)?;
}

About

Rust API for twitch's Helix.

Resources

License

Stars

Watchers

Forks

Languages