Users

class twitch.api.users.Users

This class provides methods for easy access to Twitch Users API.

classmethod get()

Gets a user object based on the OAuth token provided.

classmethod get_by_id(user_id)

Gets a user object based on specified user id.

Parameters:user_id ('string) – User ID
classmethod get_emotes(user_id)

Gets a list of the emojis and emoticons that the specified user can use in chat

Parameters:user_id ('string) – User ID
classmethod check_subscribed_to_channel(user_id, channel_id)

Checks if a specified user is subscribed to a specified channel.

Parameters:
  • user_id ('string) – User ID
  • channel_id ('string) – ID of the channel you want to check if user is subscribed to
classmethod get_follows(user_id, limit, offset, direction, sort_by)

Gets a list of all channels followed by a specified user.

Parameters:
  • user_id ('string) – User ID
  • limit (int) – Maximum number of objects to return. Default 25. Maximum 100.
  • offset (int) – Object offset for pagination of result. Default 0.
  • direction (string) – Sorting direction. Default DIRECTION_DESC.
  • sort_by (string) – Sorting key. Default USERS_SORT_BY_CREATED_AT.
classmethod check_follows_channel(user_id, channel_id)

Checks if a specified user follows a specified channel.

Parameters:
  • user_id ('string) – User ID
  • channel_id ('string) – ID of the channel you want to check if user is following
classmethod follow_channel(user_id, channel_id, notifications)

Adds a specified user to the followers of a specified channel.

Parameters:
  • user_id ('string) – User ID
  • channel_id ('string) – ID of the channel you want user to follow
  • notifications (boolean) – If true, the user gets email or push notifications when the channel goes live. Default False.
classmethod unfollow_channel(user_id, channel_id)

Deletes a specified user from the followers of a specified channel.

Parameters:
  • user_id ('string) – User ID
  • channel_id ('string) – ID of the channel you want user to unfollow
classmethod get_user_block_list(user_id, limit, offset)

Gets a user’s block list.

Parameters:
  • user_id ('string) – User ID
  • limit (int) – Maximum number of objects to return. Default 25. Maximum 100.
  • offset (int) – Object offset for pagination of result. Default 0.
classmethod block_user(user_id, blocked_user_id)

Blocks a user.

Parameters:
  • user_id ('string) – User ID
  • blocked_user_id ('string) – ID of the user you wish to block
classmethod unblock_user(user_id, blocked_user_id)

Unblocks a user.

Parameters:
  • user_id ('string) – User ID
  • blocked_user_id ('string) – ID of the user you wish to unblock
classmethod translate_usernames_to_ids(usernames)

Translates a list of usernames to user ID’s.

Parameters:usernames (list[string]) – List of usernames you wish to get ID’s of
>>> from twitch import TwitchClient
>>> client = TwitchClient('<my client id>')
>>> users = client.users.translate_usernames_to_ids(['lirik', 'giantwaffle'])
>>>
>>> for user in users:
>>>     print('{}: {}'.format(user.name, user.id))
'lirik: 23161357'
'giantwaffle: 22552479'