Modify User Details

Learn to update a user's description using the Twitch API.

Update user details

As users, we inevitably run into situations where we have to update our profile and details. The Twitch API allows us to do so using the users endpoint through a simple PUT request.

Currently, the API only allows us to update our account description through the API. However, other editable parameters may become available in the future.

All PUT requests to update a user's description need to be authorized with a user access token that has the user:edit scope.

Input parameters

Since the API only gives us the ability to update the user's account description, there is only one query parameter that is discussed in the table below:

Parameter

Type

Category

Description

description

String

Optional

This is the new description that we want to add to the account.

We can notice that the description parameter is optional. If this parameter is not provided, no fields will be updated, and no error will be returned.

Example call

Let's make a sample PUT request to this endpoint, authorizing ourselves with a user access token with the required scope, and viewing the response. We can also change the value of the description parameter on line 7 to any description of our liking.

Note: If your token has expired, return to this lesson and follow the steps to generate a new one.

Press + to interact
headers = {
'Authorization' : 'Bearer {{USER_ACCESS_TOKEN}}',
'Client-Id' : '{{CLIENT_ID}}'
}
parameters = {
'description' : 'Hello! I\'m a learner on Educative!'
}
response = requests.put('https://api.twitch.tv/helix/users',
headers=headers, params=parameters).json()
print(json.dumps(response, indent=4))

Response structure

The response from this request is the same as a GET request, with a single top-level property data containing an array of user objects. Since we can only update one user at a time, which is the user specified by the user access token, the data array will always contain a single element.

Since the token we use has both the user:edit and user:read:email scopes, the response from the API includes the email parameter. As a refresher, the table below gives an overview of the user object:

Property

Type

Description

id

String

This is the ID of the user.

login

String

This is the user's login name.

display_name

String

This is the user's display name.

type

String

This is the type of user. Its possible values are "staff""admin", and "global_mod". For users that fall under none of these types, this value is an empty string—"".

broadcaster_type

String

This is the user's broadcaster type. Its possible values are "partner" and "affiliate". For users that fall under none of these types, this value is an empty string—"".

description

String

This is the public description that the user has set on their account.

profile_image_url

String

This is the static URL of the user's profile image.

offline_image_url

String

This is the static URL of the stream placeholder image that is displayed when the user is offline.

view_count

Integer

This is the total number of views that the user's channel has accumulated.

email

String

This is the user's verified email address. It's only included if we use a user access token with the user:read:email scope.

created_at

String

This is the UTC timestamp of when the user was created.