Struct twitch_api::HelixClient
source · pub struct HelixClient<'a, C: 'a> { /* private fields */ }
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>
impl<'client, C: HttpClient + Sync + 'client> HelixClient<'client, C>
sourcepub 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,
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
sourcepub 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,
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
sourcepub async fn get_users_from_ids<T>(
&'client self,
ids: impl AsRef<[&UserIdRef]> + Send,
token: &T
) -> Result<Option<User>, ClientRequestError<<C as HttpClient>::Error>>where
T: TwitchToken + Send + Sync + ?Sized,
pub async fn get_users_from_ids<T>( &'client self, ids: impl AsRef<[&UserIdRef]> + Send, token: &T ) -> Result<Option<User>, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,
Get multiple Users from user ids.
sourcepub 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,
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
sourcepub 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,
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
sourcepub async fn get_channels_from_ids<'b, T>(
&'client self,
ids: impl AsRef<[&UserIdRef]> + Send,
token: &T
) -> Result<Vec<ChannelInformation>, ClientRequestError<<C as HttpClient>::Error>>where
T: TwitchToken + Send + Sync + ?Sized,
pub async fn get_channels_from_ids<'b, T>( &'client self, ids: impl AsRef<[&UserIdRef]> + Send, token: &T ) -> Result<Vec<ChannelInformation>, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,
Get multiple ChannelInformation from broadcasters ids
Examples
use twitch_api::{helix, types};
let ids: &[&types::UserIdRef] = &["1234".into(), "4321".into()];
let chatters: Vec<helix::channels::ChannelInformation> = client
.get_channels_from_ids(ids, &token).await?;
sourcepub 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 + 'clientwhere
T: TwitchToken + Send + Sync + ?Sized,
Available on crate feature unsupported
only.
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 + 'clientwhere T: TwitchToken + Send + Sync + ?Sized,
unsupported
only.sourcepub 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 + 'clientwhere
T: TwitchToken + Send + Sync + ?Sized,
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 + 'clientwhere 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?;
sourcepub 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 + 'clientwhere
T: TwitchToken + Send + Sync + ?Sized,
'b: 'client,
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 + 'clientwhere T: TwitchToken + Send + Sync + ?Sized, 'b: 'client,
sourcepub fn get_followed_streams<T>(
&'client self,
token: &'client T
) -> impl Stream<Item = Result<Stream, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'clientwhere
T: TwitchToken + Send + Sync + ?Sized,
pub fn get_followed_streams<T>( &'client self, token: &'client T ) -> impl Stream<Item = Result<Stream, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'clientwhere 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?;
sourcepub fn get_broadcaster_subscriptions<T>(
&'client self,
token: &'client T
) -> impl Stream<Item = Result<BroadcasterSubscription, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'clientwhere
T: TwitchToken + Send + Sync + ?Sized,
pub fn get_broadcaster_subscriptions<T>( &'client self, token: &'client T ) -> impl Stream<Item = Result<BroadcasterSubscription, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'clientwhere 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?;
sourcepub 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 + 'clientwhere
T: TwitchToken + Send + Sync + ?Sized,
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 + 'clientwhere 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?;
sourcepub 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 + 'clientwhere
T: TwitchToken + Send + Sync + ?Sized,
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 + 'clientwhere 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?;
sourcepub 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,
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
sourcepub 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 + 'clientwhere
T: TwitchToken + Send + Sync + ?Sized,
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 + 'clientwhere 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?;
sourcepub async fn get_games_by_id<T>(
&'client self,
ids: impl AsRef<[&'client CategoryIdRef]> + Send,
token: &T
) -> Result<HashMap<CategoryId, Game>, ClientRequestError<<C as HttpClient>::Error>>where
T: TwitchToken + Send + Sync + ?Sized,
pub async fn get_games_by_id<T>( &'client self, ids: impl AsRef<[&'client CategoryIdRef]> + Send, token: &T ) -> Result<HashMap<CategoryId, Game>, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,
Get games by ID. Can only be at max 100 ids.
sourcepub 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,
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
sourcepub 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,
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
sourcepub 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,
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
sourcepub 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,
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
sourcepub 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 + 'clientwhere
T: TwitchToken + Send + Sync + ?Sized,
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 + 'clientwhere 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?;
sourcepub async fn get_global_emotes<T>(
&'client self,
token: &T
) -> Result<Vec<GlobalEmote>, ClientRequestError<<C as HttpClient>::Error>>where
T: TwitchToken + Send + Sync + ?Sized,
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
sourcepub 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,
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
sourcepub 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,
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
sourcepub async fn get_emote_sets<T>(
&'client self,
emote_sets: impl AsRef<[&EmoteSetIdRef]> + Send,
token: &T
) -> Result<Vec<Emote>, ClientRequestError<<C as HttpClient>::Error>>where
T: TwitchToken + Send + Sync + ?Sized,
pub async fn get_emote_sets<T>( &'client self, emote_sets: impl AsRef<[&EmoteSetIdRef]> + Send, token: &T ) -> Result<Vec<Emote>, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,
Get emotes in emote set
sourcepub 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,
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
sourcepub 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,
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
sourcepub 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,
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
sourcepub 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,
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
sourcepub 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,
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
sourcepub 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,
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
sourcepub 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,
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 users chat color
sourcepub 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,
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,
Get a users chat color
sourcepub async fn get_users_chat_colors<T>(
&'client self,
user_ids: impl AsRef<[&UserIdRef]> + Send,
token: &T
) -> Result<Vec<UserChatColor>, ClientRequestError<<C as HttpClient>::Error>>where
T: TwitchToken + Send + Sync + ?Sized,
pub async fn get_users_chat_colors<T>( &'client self, user_ids: impl AsRef<[&UserIdRef]> + Send, token: &T ) -> Result<Vec<UserChatColor>, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,
Get multiple users chat colors
sourcepub 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,
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
sourcepub 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,
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
sourcepub 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 + 'clientwhere
T: TwitchToken + Send + Sync + ?Sized,
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 + 'clientwhere T: TwitchToken + Send + Sync + ?Sized,
Get channel VIPs
sourcepub 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,
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
sourcepub 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,
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
sourcepub 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,
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
sourcepub 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,
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?;
sourcepub async fn get_custom_rewards<'b, T>(
&'client self,
broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b,
only_managable_rewards: bool,
ids: &'b [&'b RewardIdRef],
token: &T
) -> Result<Vec<CustomReward>, ClientRequestError<<C as HttpClient>::Error>>where
T: TwitchToken + Send + Sync + ?Sized,
pub async fn get_custom_rewards<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, only_managable_rewards: bool, ids: &'b [&'b RewardIdRef], token: &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
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?;
sourcepub 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.
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,
eventsub
only.Create an EventSub subscription
sourcepub 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.
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,
eventsub
only.Delete an EventSub subscription
sourcepub 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 + 'clientwhere
T: TwitchToken + Send + Sync + ?Sized,
Available on crate feature eventsub
only.
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 + 'clientwhere T: TwitchToken + Send + Sync + ?Sized,
eventsub
only.Get all EventSub subscriptions for this Client
Notes
The return item is a struct EventSubSubscriptions
which contains the subscriptions.
See the example for getting only the 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§impl<C: HttpClient> HelixClient<'_, C>
impl<C: HttpClient> HelixClient<'_, C>
sourcepub 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.
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,
unsupported
only.Request on a valid RequestGet
endpoint, with the ability to return borrowed data and specific fields.
sourcepub 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.
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,
unsupported
only.Request on a valid RequestPost
endpoint, with the ability to return borrowed data and specific fields.
sourcepub 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>>where
R: Request + RequestPatch + RequestPatch<Body = B>,
B: HelixRequestBody,
D: Deserialize<'d> + 'd,
T: TwitchToken + ?Sized,
C: Send,
F: Fn(&R, &Uri, &str, StatusCode) -> Result<(), HelixRequestPatchError>,
Available on crate feature unsupported
only.
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>>where R: Request + RequestPatch + RequestPatch<Body = B>, B: HelixRequestBody, D: Deserialize<'d> + 'd, T: TwitchToken + ?Sized, C: Send, F: Fn(&R, &Uri, &str, StatusCode) -> Result<(), HelixRequestPatchError>,
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
sourcepub 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>>where
R: Request + RequestDelete,
D: Deserialize<'d> + 'd,
T: TwitchToken + ?Sized,
C: Send,
F: Fn(&R, &Uri, &str, StatusCode) -> Result<(), HelixRequestDeleteError>,
Available on crate feature unsupported
only.
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>>where R: Request + RequestDelete, D: Deserialize<'d> + 'd, T: TwitchToken + ?Sized, C: Send, F: Fn(&R, &Uri, &str, StatusCode) -> Result<(), HelixRequestDeleteError>,
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
sourcepub 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>>where
R: Request + RequestPut + RequestPut<Body = B>,
B: HelixRequestBody,
D: Deserialize<'d> + 'd,
T: TwitchToken + ?Sized,
C: Send,
F: Fn(&R, &Uri, &str, StatusCode) -> Result<(), HelixRequestDeleteError>,
Available on crate feature unsupported
only.
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>>where R: Request + RequestPut + RequestPut<Body = B>, B: HelixRequestBody, D: Deserialize<'d> + 'd, T: TwitchToken + ?Sized, C: Send, F: Fn(&R, &Uri, &str, StatusCode) -> Result<(), HelixRequestDeleteError>,
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>
impl<'a, C: HttpClient + 'a> HelixClient<'a, C>
sourcepub fn with_client(client: C) -> HelixClient<'a, C>
pub fn with_client(client: C) -> HelixClient<'a, C>
Create a new client with an existing client
sourcepub fn new() -> HelixClient<'a, C>where
C: ClientDefault<'a>,
pub fn new() -> HelixClient<'a, C>where C: ClientDefault<'a>,
Create a new HelixClient
with a default HttpClient
sourcepub fn clone_client(&self) -> Cwhere
C: Clone,
pub fn clone_client(&self) -> Cwhere C: Clone,
Retrieve a clone of the HttpClient
inside this HelixClient
sourcepub fn get_client(&self) -> &C
pub fn get_client(&self) -> &C
Retrieve a reference of the HttpClient
inside this HelixClient
sourcepub 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,
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;
sourcepub 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,
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
sourcepub 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,
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
sourcepub 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,
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
sourcepub 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,
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<'a, C> Clone for HelixClient<'a, C>where
C: HttpClient + Clone + 'a,
impl<'a, C> Clone for HelixClient<'a, C>where C: HttpClient + Clone + 'a,
source§impl<C: HttpClient + ClientDefault<'static>> Default for HelixClient<'static, C>
impl<C: HttpClient + ClientDefault<'static>> Default for HelixClient<'static, C>
source§fn default() -> Self
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.