Modify User Details
Learn to update a user's description using the Twitch API.
We'll cover the following
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 |
| 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.
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 |
| String | This is the ID of the user. |
| String | This is the user's login name. |
| String | This is the user's display name. |
| String | This is the type of user. Its possible values are |
| String | This is the user's broadcaster type. Its possible values are |
| String | This is the public description that the user has set on their account. |
| String | This is the static URL of the user's profile image. |
| String | This is the static URL of the stream placeholder image that is displayed when the user is offline. |
| Integer | This is the total number of views that the user's channel has accumulated. |
| String | This is the user's verified email address. It's only included if we use a user access token with the |
| String | This is the UTC timestamp of when the user was created. |