Struct HelixClient

Source
pub struct HelixClient<'a, C: 'a> { /* private fields */ }
Available on crate features client and helix only.
Expand description

Client for Helix or the New Twitch API

Use HelixClient::new or HelixClient::with_client to create a new client.

use twitch_api::HelixClient;
let helix: HelixClient<reqwest::Client> = HelixClient::new();

See req_get for GET, req_put for PUT, req_post for POST, req_patch for PATCH and req_delete for DELETE

Most clients will be able to use the 'static lifetime, which typically means it can be elided.

pub struct MyStruct {
    twitch: HelixClient<'static, reqwest::Client>,
    token: twitch_oauth2::AppAccessToken,
}
// etc

See HttpClient for implemented http clients, you can also define your own if needed.

§Examples

Get a user from their login name.

use twitch_api::helix::{users::User, HelixClient};
let client: HelixClient<'static, reqwest::Client> = HelixClient::default();
let user: Option<User> = client
    .get_user_from_login("justintv", &token)
    .await
    .unwrap();

Implementations§

Source§

impl<'client, C: HttpClient + Sync + 'client> HelixClient<'client, C>

Source

pub async fn get_user_from_login<T>( &'client self, login: impl Into<&UserNameRef> + Send, token: &T, ) -> Result<Option<User>, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Sync + Send + ?Sized,

Get User from user login

Source

pub async fn get_user_from_id<T>( &'client self, id: impl Into<&UserIdRef> + Send, token: &T, ) -> Result<Option<User>, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Get User from user id

Source

pub fn get_users_from_ids<T>( &'client self, ids: &'client Collection<'client, UserId>, token: &'client T, ) -> impl Stream<Item = Result<User, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized,

Get multiple Users from user ids.

§Examples
use twitch_api::{helix, types};
use futures::TryStreamExt;

let users: Vec<helix::users::User> = client
    .get_users_from_ids(&["1234", "4321"][..].into(), &token).try_collect().await?;
Source

pub fn get_users_from_logins<T>( &'client self, ids: &'client Collection<'client, UserName>, token: &'client T, ) -> impl Stream<Item = Result<User, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized,

Get multiple Users from user logins/nicknames.

§Examples
use twitch_api::{helix, types};
use futures::TryStreamExt;

let users: Vec<helix::users::User> = client
    .get_users_from_ids(&["twitchdev", "justintv"][..].into(), &token).try_collect().await?;
Source

pub async fn get_channel_from_login<T>( &'client self, login: impl Into<&UserNameRef> + Send, token: &T, ) -> Result<Option<ChannelInformation>, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Get ChannelInformation from a broadcasters login

Source

pub async fn get_channel_from_id<T>( &'client self, id: impl Into<&UserIdRef> + Send, token: &T, ) -> Result<Option<ChannelInformation>, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Get ChannelInformation from a broadcasters id

Source

pub fn get_channels_from_ids<T>( &'client self, ids: &'client Collection<'client, UserId>, token: &'client T, ) -> impl Stream<Item = Result<ChannelInformation, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized,

Get multiple ChannelInformation from broadcasters ids

§Examples
use twitch_api::{helix, types};
use futures::TryStreamExt;

let chatters: Vec<helix::channels::ChannelInformation> = client
    .get_channels_from_ids(&["1234", "4321"][..].into(), &token).try_collect().await?;
Source

pub fn get_streams_from_ids<T>( &'client self, ids: &'client Collection<'client, UserId>, token: &'client T, ) -> impl Stream<Item = Result<Stream, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized,

Get multiple Streams from user ids.

§Examples
use twitch_api::{types, helix};
use futures::TryStreamExt;

let live: Vec<helix::streams::Stream> = client
    .get_streams_from_ids(&["123456", "987654"][..].into(), &token)
    .try_collect()
    .await?;
Source

pub fn get_streams_from_logins<T>( &'client self, logins: &'client Collection<'client, UserName>, token: &'client T, ) -> impl Stream<Item = Result<Stream, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized,

Get multiple Streams from user logins.

§Examples
use twitch_api::{types, helix};
use futures::TryStreamExt;

let live: Vec<helix::streams::Stream> = client
    .get_streams_from_logins(&["twitchdev", "justinfan"][..].into(), &token)
    .try_collect()
    .await?;
Source

pub async fn get_stream_key<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + 'b + Send, token: &T, ) -> Result<StreamKey, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Gets the channel’s stream key.

§Examples
use twitch_api::helix;
use twitch_oauth2::TwitchToken;

// use the associated user-id  with the user-access token
let user_id = token.user_id().expect("no user-id set in token");
let key: twitch_types::StreamKey = client.get_stream_key(user_id, &token).await?;
Source

pub async fn create_stream_marker<'b, T>( &'client self, user_id: impl IntoCow<'b, UserIdRef> + 'b + Send, description: impl Into<Cow<'b, str>> + Send, token: &T, ) -> Result<CreatedStreamMarker, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Adds a marker to a live stream.

§Examples
use twitch_api::helix;
use twitch_oauth2::TwitchToken;

// use the associated user-id  with the user-access token
let user_id = token.user_id().expect("no user-id set in token");
let marker: helix::streams::CreatedStreamMarker = client.create_stream_marker(user_id, "my description", &token).await?;
Source

pub fn get_stream_markers_from_video<'b: 'client, T>( &'client self, video_id: impl IntoCow<'b, VideoIdRef> + 'b, token: &'client T, ) -> impl Stream<Item = Result<StreamMarkerGroup, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized,

Gets a list of markers from the specified VOD/video.

Markers are grouped per creator and video.

§Examples
use twitch_api::{types, helix};
use futures::TryStreamExt;

let groups: Vec<helix::streams::StreamMarkerGroup> = client
    .get_stream_markers_from_video("1234", &token)
    .try_collect()
    .await?;
Source

pub fn get_chatters<T>( &'client self, broadcaster_id: impl Into<&'client UserIdRef>, moderator_id: impl Into<&'client UserIdRef>, batch_size: impl Into<Option<usize>>, token: &'client T, ) -> impl Stream<Item = Result<Chatter, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized,

Get chatters in a stream Chatter

batch_size sets the amount of chatters to retrieve per api call, max 1000, defaults to 100.

§Examples
use twitch_api::helix;
use futures::TryStreamExt;

let chatters: Vec<helix::chat::Chatter> = client
   .get_chatters("1234", "4321", 1000, &token)
   .try_collect().await?;
Source

pub fn search_categories<T>( &'client self, query: impl Into<&'client str>, token: &'client T, ) -> impl Stream<Item = Result<Category, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized,

Search Categories

§Examples
use twitch_api::helix;
use futures::TryStreamExt;

let categories: Vec<helix::search::Category> = client
    .search_categories("Fortnite", &token)
    .try_collect().await?;
Source

pub fn search_channels<'b, T>( &'client self, query: impl Into<&'b str>, live_only: bool, token: &'client T, ) -> impl Stream<Item = Result<Channel, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized, 'b: 'client,

Search Channels via channel name or description

§Examples
use twitch_api::helix;
use futures::TryStreamExt;

let channel: Vec<helix::search::Channel> = client
    .search_channels("twitchdev", false, &token)
    .try_collect().await?;
Source

pub fn get_followed_streams<T>( &'client self, token: &'client T, ) -> impl Stream<Item = Result<Stream, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized,

Get authenticated users’ followed streams

Requires token with scope user:read:follows.

§Examples
use twitch_api::helix;
use futures::TryStreamExt;

let channels: Vec<helix::streams::Stream> = client
    .get_followed_streams(&token)
    .try_collect().await?;
Source

pub fn get_broadcaster_subscriptions<T>( &'client self, token: &'client T, ) -> impl Stream<Item = Result<BroadcasterSubscription, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized,

Get authenticated broadcasters’ subscribers

§Examples
use twitch_api::helix;
use futures::TryStreamExt;

let subs: Vec<helix::subscriptions::BroadcasterSubscription> = client
    .get_broadcaster_subscriptions(&token)
    .try_collect().await?;
Source

pub fn get_moderators_in_channel_from_id<'b: 'client, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + 'b, token: &'client T, ) -> impl Stream<Item = Result<Moderator, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized,

Get all moderators in a channel Get Moderators

§Examples
use twitch_api::helix;
use futures::TryStreamExt;

let moderators: Vec<helix::moderation::Moderator> = client
    .get_moderators_in_channel_from_id("twitchdev", &token)
    .try_collect().await?;
Source

pub fn get_banned_users_in_channel_from_id<'b: 'client, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + 'b, token: &'client T, ) -> impl Stream<Item = Result<BannedUser, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized,

Get all banned users in a channel Get Banned Users

§Examples
use twitch_api::helix;
use futures::TryStreamExt;

let moderators: Vec<helix::moderation::BannedUser> = client.get_banned_users_in_channel_from_id("twitchdev", &token).try_collect().await?;
Source

pub fn get_unban_requests<'b: 'client, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + 'b, moderator_id: impl IntoCow<'b, UserIdRef> + 'b, status: UnbanRequestStatus, token: &'client T, ) -> impl Stream<Item = Result<UnbanRequest, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized,

Gets a list of unban requests for a broadcaster’s channel. Get Unban Requests

§Examples
use twitch_api::helix;
use futures::TryStreamExt;

let requests: Vec<helix::moderation::UnbanRequest> = client.get_unban_requests("1234", "5678", helix::moderation::UnbanRequestStatus::Pending, &token).try_collect().await?;
Source

pub fn get_moderated_channels<'b: 'client, T>( &'client self, user_id: impl IntoCow<'b, UserIdRef> + 'b, token: &'client T, ) -> impl Stream<Item = Result<ModeratedChannel, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized,

Gets a list of channels that the specified user has moderator privileges in. Get Moderated Channels

§Examples
use twitch_api::helix;
use twitch_oauth2::TwitchToken;
use futures::TryStreamExt;

// use the associated user-id  with the user-access token
let user_id = token.user_id().expect("no user-id set in token");
let requests: Vec<helix::moderation::ModeratedChannel> = client.get_moderated_channels(user_id, &token).try_collect().await?;
Source

pub async fn get_total_channel_followers<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T, ) -> Result<i64, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Get a broadcasters follow count

§Notes

You need to have the scope moderator:read:followers and be a moderator of the channel if the token is not the broadcasters own token

Source

pub fn get_followed_channels<'b: 'client, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + 'b, token: &'client T, ) -> impl Stream<Item = Result<FollowedBroadcaster, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized,

Get users followed channels

§Examples
use twitch_api::helix;
use futures::TryStreamExt;

let schedule: Vec<helix::channels::FollowedBroadcaster> = client
    .get_followed_channels("1234", &token)
    .try_collect()
    .await?;
Source

pub fn get_games_by_id<T>( &'client self, ids: &'client Collection<'client, CategoryId>, token: &'client T, ) -> impl Stream<Item = Result<Game, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized,

Get games by ID.

§Examples
use twitch_api::{types, helix};
use futures::TryStreamExt;

let games: Vec<helix::games::Game> = client
    .get_games_by_id(&["509658", "32982", "27471"][..].into(), &token).try_collect().await?;
Source

pub async fn block_user<'b, T>( &'client self, target_user_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T, ) -> Result<BlockUser, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Block a user

Source

pub async fn unblock_user<'b, T>( &'client self, target_user_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T, ) -> Result<UnblockUser, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Unblock a user

Source

pub async fn ban_user<'b, T>( &'client self, target_user_id: impl IntoCow<'b, UserIdRef> + Send + 'b, reason: impl Into<&'b str> + Send, duration: impl Into<Option<u32>> + Send, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, moderator_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T, ) -> Result<BanUser, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Ban a user

Source

pub async fn unban_user<'b, T>( &'client self, target_user_id: impl IntoCow<'b, UserIdRef> + Send + 'b, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, moderator_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T, ) -> Result<UnbanUserResponse, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Unban a user

Source

pub async fn warn_chat_user<'b, T>( &'client self, target_user_id: impl IntoCow<'b, UserIdRef> + Send + 'b, reason: impl Into<&'b str> + Send, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, moderator_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T, ) -> Result<WarnChatUser, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Available on crate feature beta only.

Warn a user

Source

pub fn get_channel_schedule<'b: 'client, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + 'b, token: &'client T, ) -> impl Stream<Item = Result<Segment, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized,

Get all scheduled streams in a channel.

§Notes

Make sure to limit the data here using try_take_while, otherwise this will never end on recurring scheduled streams.

§Examples
use twitch_api::helix;
use futures::TryStreamExt;

let schedule: Vec<helix::schedule::Segment> = client
    .get_channel_schedule("twitchdev", &token)
    .try_take_while(|s| {
        futures::future::ready(Ok(!s.start_time.as_str().starts_with("2021-10")))
    })
    .try_collect()
    .await?;
Source

pub async fn get_global_emotes<T>( &'client self, token: &T, ) -> Result<Vec<GlobalEmote>, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Get all global emotes

Source

pub async fn get_channel_emotes_from_id<'b, T>( &'client self, user_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T, ) -> Result<Vec<ChannelEmote>, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Get channel emotes in channel with user id

Source

pub async fn get_channel_emotes_from_login<T>( &'client self, login: impl IntoCow<'client, UserNameRef> + Send + 'client, token: &T, ) -> Result<Option<Vec<ChannelEmote>>, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Get channel emotes in channel with user login

Source

pub fn get_user_emotes<'b: 'client, T>( &'client self, user_id: impl IntoCow<'b, UserIdRef> + 'b, token: &'client T, ) -> impl Stream<Item = Result<UserEmote, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized,

Get all emotes accessible to the user in all chats.

§Examples
use twitch_api::helix;
use twitch_oauth2::TwitchToken;
use futures::TryStreamExt;

// use the associated user-id with the user-access token
let user_id = token.user_id().expect("no user-id set in token");
let requests: Vec<helix::chat::UserEmote> = client.get_user_emotes(user_id, &token).try_collect().await?;
Source

pub fn get_user_emotes_in_channel<'b: 'client, 'c: 'client, T>( &'client self, user_id: impl IntoCow<'b, UserIdRef> + 'b, channel_id: impl IntoCow<'c, UserIdRef> + 'c, token: &'client T, ) -> impl Stream<Item = Result<UserEmote, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized,

Get all emotes accessible to the user in a channel.

This will include “follow” emotes if the user isn’t subscribed but following.

§Examples
use twitch_api::helix;
use twitch_oauth2::TwitchToken;
use futures::TryStreamExt;

// use the associated user-id with the user-access token
let user_id = token.user_id().expect("no user-id set in token");
let requests: Vec<helix::chat::UserEmote> = client.get_user_emotes_in_channel(user_id, "1234", &token).try_collect().await?;
Source

pub fn get_emote_sets<T>( &'client self, emote_sets: &'client Collection<'client, EmoteSetId>, token: &'client T, ) -> impl Stream<Item = Result<Emote, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized,

Get emotes in emote sets

§Examples
use twitch_api::{types, helix};
use futures::TryStreamExt;

let emotes: Vec<helix::chat::get_emote_sets::Emote> = client
    .get_emote_sets(&["0"][..].into(), &token).try_collect().await?;
Source

pub async fn get_chat_settings<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, moderator_id: impl Into<Option<&'b UserIdRef>> + Send + 'b, token: &T, ) -> Result<ChatSettings, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Get a broadcaster’s chat settings

Source

pub async fn send_chat_announcement<'b, T, E>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, moderator_id: impl IntoCow<'b, UserIdRef> + Send + 'b, message: impl Into<&'b str> + Send, color: impl TryInto<AnnouncementColor, Error = E> + Send, token: &T, ) -> Result<SendChatAnnouncementResponse, ClientExtError<C, E>>
where T: TwitchToken + Send + Sync + ?Sized,

Send a chat announcement

Source

pub async fn send_chat_message<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, sender_id: impl IntoCow<'b, UserIdRef> + Send + 'b, message: impl Into<&'b str> + Send, token: &T, ) -> Result<SendChatMessageResponse, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Send a chat message

Source

pub async fn send_chat_message_reply<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, sender_id: impl IntoCow<'b, UserIdRef> + Send + 'b, reply_parent_message_id: impl IntoCow<'b, MsgIdRef> + Send + 'b, message: impl Into<&'b str> + Send, token: &T, ) -> Result<SendChatMessageResponse, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Send a chat message reply

Source

pub async fn delete_chat_message<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, moderator_id: impl IntoCow<'b, UserIdRef> + Send + 'b, message_id: impl IntoCow<'b, MsgIdRef> + Send + 'b, token: &T, ) -> Result<DeleteChatMessagesResponse, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Delete a specific chat message

Source

pub async fn delete_all_chat_message<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, moderator_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T, ) -> Result<DeleteChatMessagesResponse, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Delete all chat messages in a broadcasters chat room

Source

pub async fn start_a_raid<'b, T>( &'client self, from_broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, to_broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T, ) -> Result<StartARaidResponse, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Start a raid

Source

pub async fn cancel_a_raid<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T, ) -> Result<CancelARaidResponse, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Cancel a raid

Source

pub async fn update_user_chat_color<'b, T>( &'client self, user_id: impl IntoCow<'b, UserIdRef> + Send + 'b, color: impl Into<NamedUserColor<'b>> + Send + 'b, token: &T, ) -> Result<UpdateUserChatColorResponse, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Update a user’s chat color

Source

pub async fn get_user_chat_color<T>( &'client self, user_id: impl Into<&UserIdRef> + Send, token: &T, ) -> Result<Option<UserChatColor>, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Get a user’s chat color

None is returned if the user never set their color in the settings.

Source

pub fn get_users_chat_colors<T>( &'client self, user_ids: &'client Collection<'client, UserId>, token: &'client T, ) -> impl Stream<Item = Result<UserChatColor, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized,

Get multiple users’ chat colors

Users that never set their color in the settings are not returned.

§Examples
use twitch_api::{types, helix};
use futures::TryStreamExt;

let colors: Vec<helix::chat::UserChatColor> = client
    .get_users_chat_colors(&["1234"][..].into(), &token).try_collect().await?;
Source

pub async fn update_user_description<'b, T>( &'client self, description: impl Into<Cow<'b, str>> + Send, token: &T, ) -> Result<User, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Update the user’s description

The user ID in the OAuth token identifies the user whose information you want to update.

Source

pub async fn get_user_extensions<'b, T>( &'client self, token: &T, ) -> Result<Vec<Extension>, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Gets a list of all extensions (both active and inactive) that the broadcaster has installed.

The user ID in the access token identifies the broadcaster.

Source

pub async fn get_user_active_extensions<'b, T>( &'client self, token: &T, ) -> Result<ExtensionConfiguration, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Gets the active extensions that the broadcaster has installed for each configuration.

The user ID in the access token identifies the broadcaster.

Source

pub async fn get_shared_chat_session<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T, ) -> Result<Option<SharedChatSession>, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Retrieves the active shared chat session for a channel

None is returned if no shared chat session is active.

Source

pub async fn add_channel_moderator<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, moderator_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T, ) -> Result<AddChannelModeratorResponse, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Add a channel moderator

Source

pub async fn remove_channel_moderator<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, moderator_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T, ) -> Result<RemoveChannelModeratorResponse, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Remove a channel moderator

Source

pub fn get_vips_in_channel<'b: 'client, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + 'b, token: &'client T, ) -> impl Stream<Item = Result<Vip, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized,

Get channel VIPs

Source

pub async fn add_channel_vip<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, user_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T, ) -> Result<AddChannelVipResponse, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Add a channel vip

Source

pub async fn remove_channel_vip<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, user_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T, ) -> Result<RemoveChannelVipResponse, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Remove a channel vip

Source

pub async fn send_whisper<'b, T>( &'client self, from: impl IntoCow<'b, UserIdRef> + Send + 'b, to: impl IntoCow<'b, UserIdRef> + Send + 'b, message: impl Into<&'b str> + Send, token: &T, ) -> Result<SendWhisperResponse, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Send a whisper

Source

pub async fn get_all_custom_rewards<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, only_managable_rewards: bool, token: &T, ) -> Result<Vec<CustomReward>, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Get all custom rewards

§Examples
use twitch_api::helix;

let rewards: Vec<helix::points::CustomReward> = client
    .get_all_custom_rewards("1234", true, &token)
    .await?;
Source

pub async fn get_custom_rewards<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, only_managable_rewards: bool, ids: &'b Collection<'b, RewardId>, token: &'client T, ) -> Result<Vec<CustomReward>, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Get specific custom rewards, see get_all_custom_rewards to get all rewards

§Notes

Takes a max of 50 ids

§Examples
use twitch_api::helix;

let rewards: Vec<helix::points::CustomReward> = client
    .get_custom_rewards("1234", true, &["8969ec47-55b6-4559-a8fe-3f1fc4e6fe58"][..].into(), &token)
    .await?;
Source

pub async fn get_content_classification_labels<'b, T>( &'client self, token: &'client T, ) -> Result<Vec<ContentClassificationLabel>, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Get information about Twitch content classification labels, see get_content_classification_labels_for_locale to get the labels in a specific locale.

§Examples
use twitch_api::helix;

let labels: Vec<helix::ccls::ContentClassificationLabel> = client
    .get_content_classification_labels(&token)
    .await?;
Source

pub async fn get_content_classification_labels_for_locale<'b, T>( &'client self, locale: impl Into<Cow<'b, str>> + 'b + Send, token: &'client T, ) -> Result<Vec<ContentClassificationLabel>, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Get information about Twitch content classification labels for a specific locale.

§Examples
use twitch_api::helix;

let labels: Vec<helix::ccls::ContentClassificationLabel> = client
    .get_content_classification_labels_for_locale("fi-FI", &token)
    .await?;
Source

pub async fn create_eventsub_subscription<T, E: EventSubscription + Send>( &'client self, subscription: E, transport: Transport, token: &T, ) -> Result<CreateEventSubSubscription<E>, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Available on crate feature eventsub only.

Create an EventSub subscription

Source

pub async fn delete_eventsub_subscription<'b, T>( &'client self, id: impl IntoCow<'b, EventSubIdRef> + Send + 'b, token: &T, ) -> Result<DeleteEventSubSubscription, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Available on crate feature eventsub only.

Delete an EventSub subscription

Source

pub fn get_eventsub_subscriptions<'b: 'client, T>( &'client self, status: impl Into<Option<Status>>, event_type: impl Into<Option<EventType>>, user_id: Option<&'b UserIdRef>, token: &'client T, ) -> impl Stream<Item = Result<EventSubSubscriptions, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized,

Available on crate feature eventsub only.

Get all EventSub subscriptions for this Client

§Notes

The return item is a struct EventSubSubscriptions which contains a field with all the subscriptions. See the example for collecting all specific subscriptions

§Examples
use twitch_api::{helix, eventsub};
use futures::{TryStreamExt, stream};

let mut total_cost = None;

let chatters: Vec<eventsub::EventSubSubscription> = client
    .get_eventsub_subscriptions(None, None, None, &token)
    .map_ok(|r| {
        total_cost = Some(r.total_cost);
        stream::iter(
            r.subscriptions
                .into_iter()
                .map(Ok::<_, twitch_api::helix::ClientRequestError<_>>),
        )
    })
    .try_flatten()
    .try_collect()
    .await?;
Source

pub async fn get_conduits<'b: 'client, T>( &'client self, token: &'client T, ) -> Result<Vec<Conduit>, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Available on crate feature eventsub only.

Get all Conduits for the Twitch Developer Application associated with this token

§Notes

The token must be an App Access Token

§Examples
use twitch_api::{helix, eventsub};

let conduits = client.get_conduits(&token).await?;
Source

pub async fn create_conduit<T>( &'client self, shard_count: usize, token: &'client T, ) -> Result<Conduit, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Available on crate feature eventsub only.

Create a Conduit for the Twitch Developer Application associated with this token

§Notes

The token must be an App Access Token

§Examples
use twitch_api::{helix, eventsub};

let shard_count = 5;
let created_conduit = client.create_conduit(shard_count, &token).await?;
Source

pub fn get_conduit_shards<'b: 'client, T>( &'client self, conduit_id: impl IntoCow<'b, ConduitIdRef> + 'b, status: impl Into<Option<ShardStatus>>, token: &'client T, ) -> impl Stream<Item = Result<ShardResponse, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
where T: TwitchToken + Send + Sync + ?Sized,

Available on crate feature eventsub only.

Gets a list of all shards for a conduit.

§Notes

The token must be an App Access Token

§Examples
§Get all shards from the given conduit
use twitch_api::{helix, eventsub};
use futures::TryStreamExt;

let conduit_id = "26b1c993-bfcf-44d9-b876-379dacafe75a";
let status = None;
let all_shards: Vec<eventsub::ShardResponse> = client
    .get_conduit_shards(conduit_id, status, &token)
    .try_collect().await?;
§Get all enabled shards from the given conduit
use twitch_api::{helix, eventsub};
use futures::TryStreamExt;

let conduit_id = "26b1c993-bfcf-44d9-b876-379dacafe75a";
let status = eventsub::ShardStatus::Enabled;
let enabled_shards: Vec<eventsub::ShardResponse> = client
    .get_conduit_shards(conduit_id, status, &token)
    .try_collect().await?;
Source

pub async fn update_conduit<'b: 'client, T>( &'client self, conduit_id: impl IntoCow<'b, ConduitIdRef> + 'b + Send, shard_count: usize, token: &'client T, ) -> Result<Conduit, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Available on crate feature eventsub only.

Updates a conduit’s shard count..

§Notes

To delete shards, update the count to a lower number, and the shards above the count will be deleted. For example, if the existing shard count is 100, by resetting shard count to 50, shards 50-99 are disabled.

The token must be an App Access Token.

§Examples
use twitch_api::{helix, eventsub};

// The conduit ID of a previously created Conduit
let conduit_id = "bb7a1803-eb03-41ef-a1ab-e9242e72053e";
let shard_count = 5;
let updated: eventsub::Conduit = client
    .update_conduit(conduit_id, shard_count, &token)
    .await?;
Source

pub async fn delete_conduit<'b: 'client, T>( &'client self, conduit_id: impl IntoCow<'b, ConduitIdRef> + 'b + Send, token: &'client T, ) -> Result<(), ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Available on crate feature eventsub only.

Deletes a specified conduit.

§Notes

Note that it may take some time for Eventsub subscriptions on a deleted conduit to show as disabled when calling Get Eventsub Subscriptions.

The token must be an App Access Token.

§Examples
use twitch_api::{helix, eventsub};

// The conduit ID of a previously created Conduit
let conduit_id = "bb7a1803-eb03-41ef-a1ab-e9242e72053e";
client
    .delete_conduit(conduit_id, &token)
    .await?;
Source

pub async fn update_conduit_shards<'b: 'client, T>( &'client self, conduit_id: impl IntoCow<'b, ConduitIdRef> + 'b + Send, shards: impl Into<Cow<'b, [Shard]>> + Send, token: &'client T, ) -> Result<UpdateConduitShardsResponse, ClientRequestError<<C as HttpClient>::Error>>
where T: TwitchToken + Send + Sync + ?Sized,

Available on crate feature eventsub only.

Updates the Shard for the given Conduit.

This is used to connect a Webhook or Websocket transport to a conduit, which you can read more about here

§Notes

Shard IDs are indexed starting at 0, so a conduit with a shard_count of 5 will have shards with IDs 0 through 4.

The token must be an App Access Token

§Examples
use twitch_api::{helix, eventsub};

// The conduit ID of a previously created Conduit
let conduit_id = "bb7a1803-eb03-41ef-a1ab-e9242e72053e";
// The session ID of your WebSocket EventSub connection
let session_id = "AgoQMpdhHZ-dSoyv7NLALgOGHhIGY2VsbC1j";
let shard = twitch_api::eventsub::Shard::new(
    "0",
    twitch_api::eventsub::Transport::websocket(session_id),
);

let response = client
    .update_conduit_shards(conduit_id, &[shard], &token)
    .await;
Source§

impl<C: HttpClient> HelixClient<'_, C>

Source

pub async fn req_get_custom<'d, R, D, T>( &self, request: R, token: &T, ) -> Result<CustomResponse<'d, R, D>, ClientRequestError<<C as HttpClient>::Error>>
where R: Request + RequestGet, D: Deserialize<'d> + 'd, T: TwitchToken + ?Sized, C: Send,

Available on crate feature unsupported only.

Request on a valid RequestGet endpoint, with the ability to return borrowed data and specific fields.

Source

pub async fn req_post_custom<'d, R, B, D, T>( &self, request: R, body: B, token: &T, ) -> Result<CustomResponse<'d, R, D>, ClientRequestError<<C as HttpClient>::Error>>
where R: Request + RequestPost + RequestPost<Body = B>, B: HelixRequestBody, D: Deserialize<'d> + 'd, T: TwitchToken + ?Sized, C: Send,

Available on crate feature unsupported only.

Request on a valid RequestPost endpoint, with the ability to return borrowed data and specific fields.

Source

pub async fn req_patch_custom<'d, R, B, D, T, F>( &self, request: R, body: B, token: &T, function: F, ) -> Result<CustomResponse<'d, R, D>, ClientRequestError<<C as HttpClient>::Error>>

Available on crate feature unsupported only.

Request on a valid RequestPatch endpoint, with the ability to return borrowed data and specific fields.

§Notes

This is probably not useful, as PATCH endpoints do not usually return json

Source

pub async fn req_delete_custom<'d, R, D, T, F>( &self, request: R, token: &T, function: F, ) -> Result<CustomResponse<'d, R, D>, ClientRequestError<<C as HttpClient>::Error>>

Available on crate feature unsupported only.

Request on a valid RequestDelete endpoint, with the ability to return borrowed data and specific fields.

§Notes

This is probably not useful, as DELETE endpoints do not usually return json

Source

pub async fn req_put_custom<'d, R, B, D, T, F>( &self, request: R, body: B, token: &T, function: F, ) -> Result<CustomResponse<'d, R, D>, ClientRequestError<<C as HttpClient>::Error>>

Available on crate feature unsupported only.

Request on a valid RequestPut endpoint, with the ability to return borrowed data and specific fields.

§Notes

This is probably not useful, as PUT endpoints do not usually return json

Source§

impl<'a, C: HttpClient + 'a> HelixClient<'a, C>

Source

pub const fn with_client(client: C) -> Self

Create a new client with an existing client

Source

pub fn new() -> Self
where C: ClientDefault<'a>,

Create a new HelixClient with a default HttpClient

Source

pub fn clone_client(&self) -> C
where C: Clone,

Retrieve a clone of the HttpClient inside this HelixClient

Source

pub const fn get_client(&self) -> &C

Retrieve a reference of the HttpClient inside this HelixClient

Source

pub async fn req_get<R, D, T>( &'a self, request: R, token: &T, ) -> Result<Response<R, D>, ClientRequestError<<C as HttpClient>::Error>>
where R: Request<Response = D> + Request + RequestGet, D: DeserializeOwned + PartialEq, T: TwitchToken + ?Sized, C: Send,

Request on a valid RequestGet endpoint

let ids: &[&twitch_types::UserIdRef] = &["123456".into()];
let req = channels::GetChannelInformationRequest::broadcaster_ids(ids);
let client = HelixClient::new();

let response = client.req_get(req, &token).await;
Source

pub async fn req_post<R, B, D, T>( &'a self, request: R, body: B, token: &T, ) -> Result<Response<R, D>, ClientRequestError<<C as HttpClient>::Error>>
where R: Request<Response = D> + Request + RequestPost<Body = B>, B: HelixRequestBody, D: DeserializeOwned + PartialEq, T: TwitchToken + ?Sized,

Request on a valid RequestPost endpoint

Source

pub async fn req_patch<R, B, D, T>( &'a self, request: R, body: B, token: &T, ) -> Result<Response<R, D>, ClientRequestError<<C as HttpClient>::Error>>
where R: Request<Response = D> + Request + RequestPatch<Body = B>, B: HelixRequestBody, D: DeserializeOwned + PartialEq, T: TwitchToken + ?Sized,

Request on a valid RequestPatch endpoint

Source

pub async fn req_delete<R, D, T>( &'a self, request: R, token: &T, ) -> Result<Response<R, D>, ClientRequestError<<C as HttpClient>::Error>>
where R: Request<Response = D> + Request + RequestDelete, D: DeserializeOwned + PartialEq, T: TwitchToken + ?Sized,

Request on a valid RequestDelete endpoint

Source

pub async fn req_put<R, B, D, T>( &'a self, request: R, body: B, token: &T, ) -> Result<Response<R, D>, ClientRequestError<<C as HttpClient>::Error>>
where R: Request<Response = D> + Request + RequestPut<Body = B>, B: HelixRequestBody, D: DeserializeOwned + PartialEq, T: TwitchToken + ?Sized,

Request on a valid RequestPut endpoint

Trait Implementations§

Source§

impl<'c, C: Client + Sync + 'c> Client for HelixClient<'c, C>

Source§

type Error = CompatError<<C as Client>::Error>

Error returned by the client
Source§

fn req( &self, request: Request<Vec<u8>>, ) -> BoxedFuture<'_, Result<Response<Vec<u8>>, <Self as Client>::Error>>

Send a request
Source§

impl<'a, C> Clone for HelixClient<'a, C>
where C: HttpClient + Clone + 'a,

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<C: HttpClient + ClientDefault<'static>> Default for HelixClient<'static, C>

Source§

fn default() -> Self

Creates a new HelixClient with a default HttpClient.

See ClientDefault::default_client_with_name for setting a product name in the User Agent.

Auto Trait Implementations§

§

impl<'a, C> Freeze for HelixClient<'a, C>
where C: Freeze,

§

impl<'a, C> RefUnwindSafe for HelixClient<'a, C>
where C: RefUnwindSafe,

§

impl<'a, C> Send for HelixClient<'a, C>
where C: Send,

§

impl<'a, C> Sync for HelixClient<'a, C>
where C: Sync,

§

impl<'a, C> Unpin for HelixClient<'a, C>
where C: Unpin,

§

impl<'a, C> UnwindSafe for HelixClient<'a, C>
where C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,