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>>
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>>
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>>
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>>
Get User from user id
Sourcepub 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
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
Sourcepub 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
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
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>>
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>>
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>>
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>>
Get ChannelInformation from a broadcasters id
Sourcepub 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
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
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?;
Sourcepub 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
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
Sourcepub 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
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
Sourcepub 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>>
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>>
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?;
Sourcepub 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>>
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>>
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?;
Sourcepub 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
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
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?;
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 + 'client
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
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?;
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 + 'client
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
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 + '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 + 'client
Sourcepub fn get_followed_streams<T>(
&'client self,
token: &'client T,
) -> impl Stream<Item = Result<Stream, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
pub fn get_followed_streams<T>( &'client self, token: &'client T, ) -> impl Stream<Item = Result<Stream, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
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 + 'client
pub fn get_broadcaster_subscriptions<T>( &'client self, token: &'client T, ) -> impl Stream<Item = Result<BroadcasterSubscription, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'client
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 + 'client
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
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 + 'client
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
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 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
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
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?;
Sourcepub 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
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
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?;
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>>
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>>
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 + 'client
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
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 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
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
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?;
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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>>
Unban a user
Sourcepub 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>>
Available on crate feature beta
only.
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>>
beta
only.Warn 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 + 'client
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
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>>
pub async fn get_global_emotes<T>( &'client self, token: &T, ) -> Result<Vec<GlobalEmote>, ClientRequestError<<C as HttpClient>::Error>>
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>>
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>>
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>>
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>>
Get channel emotes in channel with user login
Sourcepub 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
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
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?;
Sourcepub 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
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
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?;
Sourcepub 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
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
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?;
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>>
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>>
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>>
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>>
Send a chat announcement
Sourcepub 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>>
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>>
Send a chat message
Sourcepub 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>>
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>>
Send a chat message reply
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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>>
Cancel a raid
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>>
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>>
Update a user’s chat color
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>>
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>>
Get a user’s chat color
None
is returned if the user never set their color in the settings.
Sourcepub 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
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
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?;
Sourcepub 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>>
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>>
Update the user’s description
The user ID in the OAuth token identifies the user whose information you want to update.
Sourcepub async fn get_user_extensions<'b, T>(
&'client self,
token: &T,
) -> Result<Vec<Extension>, ClientRequestError<<C as HttpClient>::Error>>
pub async fn get_user_extensions<'b, T>( &'client self, token: &T, ) -> Result<Vec<Extension>, ClientRequestError<<C as HttpClient>::Error>>
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.
Sourcepub async fn get_user_active_extensions<'b, T>(
&'client self,
token: &T,
) -> Result<ExtensionConfiguration, ClientRequestError<<C as HttpClient>::Error>>
pub async fn get_user_active_extensions<'b, T>( &'client self, token: &T, ) -> Result<ExtensionConfiguration, ClientRequestError<<C as HttpClient>::Error>>
Gets the active extensions that the broadcaster has installed for each configuration.
The user ID in the access token identifies the broadcaster.
Retrieves the active shared chat session for a channel
None
is returned if no shared chat session is active.
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>>
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>>
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>>
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>>
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 + 'client
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
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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 Collection<'b, RewardId>,
token: &'client T,
) -> Result<Vec<CustomReward>, ClientRequestError<<C as HttpClient>::Error>>
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>>
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?;
Sourcepub async fn get_content_classification_labels<'b, T>(
&'client self,
token: &'client T,
) -> Result<Vec<ContentClassificationLabel>, ClientRequestError<<C as HttpClient>::Error>>
pub async fn get_content_classification_labels<'b, T>( &'client self, token: &'client T, ) -> Result<Vec<ContentClassificationLabel>, ClientRequestError<<C as HttpClient>::Error>>
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?;
Sourcepub 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>>
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>>
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?;
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>>
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>>
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>>
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>>
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 + 'client
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 + 'client
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?;
Sourcepub async fn get_conduits<'b: 'client, T>(
&'client self,
token: &'client T,
) -> Result<Vec<Conduit>, ClientRequestError<<C as HttpClient>::Error>>
Available on crate feature eventsub
only.
pub async fn get_conduits<'b: 'client, T>( &'client self, token: &'client T, ) -> Result<Vec<Conduit>, ClientRequestError<<C as HttpClient>::Error>>
eventsub
only.Sourcepub async fn create_conduit<T>(
&'client self,
shard_count: usize,
token: &'client T,
) -> Result<Conduit, ClientRequestError<<C as HttpClient>::Error>>
Available on crate feature eventsub
only.
pub async fn create_conduit<T>( &'client self, shard_count: usize, token: &'client T, ) -> Result<Conduit, ClientRequestError<<C as HttpClient>::Error>>
eventsub
only.Sourcepub 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
Available on crate feature eventsub
only.
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
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?;
Sourcepub 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>>
Available on crate feature eventsub
only.
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>>
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?;
Sourcepub 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>>
Available on crate feature eventsub
only.
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>>
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?;
Sourcepub 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>>
Available on crate feature eventsub
only.
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>>
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>
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>>
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>>
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 const fn with_client(client: C) -> Self
pub const fn with_client(client: C) -> Self
Create a new client with an existing client
Sourcepub fn new() -> Selfwhere
C: ClientDefault<'a>,
pub fn new() -> Selfwhere
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 const fn get_client(&self) -> &C
pub const 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.