GetAvatar#
The method returns a user or a group chat avatar.
Request#
To get avatar, you have to execute a request at:
POST https://api.green-api.com/waInstance{{idInstance}}/GetAvatar/{{apiTokenInstance}}
For idInstance
and apiTokenInstance
request parameters, refer to Before you start section.
Request parameters#
Parameter | Type | Mandatory | Description |
---|---|---|---|
chatId | string | Yes | User or group chat Id |
Request body example#
To get your avatar - specify your number in chatId ("{your number}@c.us").
Get user avatar:
{
"chatId": "11001234567@c.us"
}
Get group chat avatar:
{
"chatId": "11001234567-1581234048@g.us"
}
Response#
Response parameters#
Parameter | Type | Description |
---|---|---|
existsWhatsapp | boolean | Flag of WhatsApp account availability on the correspondent's phone number |
urlAvatar | string | Link to a user or a group chat avatar. The parameter takes an empty value if the avatar is not set or the user does not have a WhatsApp account (existsWhatsapp =false ) |
reason | string | Reason why avatar has not been checked. Present when the check has not been successful, possible variants: |
bad request data - Invalid phone number format. Telephone number must be 11 or 12 digits. Or chat Id | ||
get avatar timeout limit exceeded - The timeout for a response to check avatar availabiity has been exceeded |
Response body example#
{
"existsWhatsapp": true,
"urlAvatar": "https://pps.whatsapp.net/v/link/to/the/image"
}
GetAvatar errors#
For a list of errors common to all methods, refer to Common errors section
HTTP code | Error Id | Description |
---|---|---|
200 | bad request data | Invalid phone number format. Telephone number must be 11 or 12 digits. Or chat Id |
200 | get avatar timeout limit exceeded | The timeout for a response to check avatar availabiity has been exceeded |
Python request example#
import requests
url = "https://api.green-api.com/waInstance{{idInstance}}/getAvatar/{{apiTokenInstance}}"
payload = "{\r\n \"chatId\": \"11001234567@c.us\"\r\n}"
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data = payload)
print(response.text.encode('utf8'))