GetContactInfo#
The method is intended for getting information about a contact.
Request#
To get information about a contact, you need to execute a request at:
POST
{{apiUrl}}/waInstance{{idInstance}}/getContactInfo/{{apiTokenInstance}}
To get the apiUrl, idInstance and apiTokenInstance request parameters, refer to the Before you start section.
Request parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
chatId | string | Yes | Chat identifier |
Request body example#
{
"chatId": "10000000"
}
Response#
Response fields#
| Field | Type | Description |
|---|---|---|
avatar | string | Link to the avatar |
name | string | Contact name |
contactName | string | Contact name from the phone book |
chatId | string | Chat identifier |
chatType | string | Account type |
lastSeen | integer | Time of the last online status If it is hidden by privacy settings, it will take the value 0 |
phoneNumber | integer | Contact's phone number |
username | string | Public profile name that starts with the @ character |
isPremium | boolean | Premium account flag, true/false |
isVerified | boolean | Verified account flag, true/false |
isScam | boolean | true if many users have reported this user as a scammer |
description | string | Account description ("About" / "Bio") |
Response body example#
{
"avatar": "https://4100.api.green-api.com/download/4100/BTZ4NuB7eCzxAQozwDKYmcUEvgSXr.jpg",
"name": "Vasilisa",
"contactName": "Vasilisa the Wise",
"chatId": "100000000",
"chatType": "user",
"lastSeen": 1769681957,
"phoneNumber": 79876543210,
"username": "@vasilisa",
"isPremium": true,
"isVerified": false,
"isScam": false,
"description": ""
}
GetContactInfo errors#
For the list of errors common to all methods, see the Common errors section
| HTTP code | Error identifier | Description |
|---|---|---|
| 400 | Bad Request Validation failed | Validation error |
| 400 | Bad Request Validation failed. Details: The method GetContactInfo does not support group chats, to work with groups, use the GetGroupData method | An empty request body or an incorrect chatId or the method was used with a groupId |
| 400 | user with required chatId is deleted | The account with the specified chatId has been deleted |
| 500 | Internal Server Error interface conversion: interface {} is bool, not string | Incorrect data type of the chatId field |
Code examples#
import requests
url = "{{apiUrl}}/waInstance{{idInstance}}/getContactInfo/{{apiTokenInstance}}"
payload = {
"chatId": "10000000"
}
response = requests.post(url, json=payload)
print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/getContactInfo/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"chatId": "71234567890@c.us"
}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
.append({{apiUrl}})
.append("/waInstance").append({{idInstance}})
.append("/getContactInfo/")
.append({{apiTokenInstance}});
var headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
var jsonBody = "{\"chatId\": \"10000000\"}";
var requestEntity = new HttpEntity<>(jsonBody, headers);
var response = restTemplate.exchange(requestUrl.toString(), HttpMethod.POST, requestEntity, String.class);
System.out.println(response);
var requestUrl = new StringBuilder();
requestUrl
.append({{apiUrl}})
.append("/waInstance").append({{idInstance}})
.append("/getContactInfo/")
.append({{apiTokenInstance}});
var response = Unirest.post(requestUrl.toString())
.header("Content-Type", "application/json")
.body("{\"chatId\": \"10000000\"}")
.asString();
System.out.println(response);
Sub GetContactInfo()
Dim url As String
Dim RequestBody As String
Dim http As Object
Dim response As String
' The apiUrl, idInstance and apiTokenInstance values are available in console, double brackets must be removed
url = "{{apiUrl}}/waInstance{{idInstance}}/GetContactInfo/{{apiTokenInstance}}"
' chatId - is the number to send the message to (@c.us for private chats, @g.us for group chats)
RequestBody = "{""chatId"":""10000000""}"
Set http = CreateObject("MSXML2.XMLHTTP")
With http
.Open "POST", url, False
.setRequestHeader "Content-Type", "application/json"
.Send RequestBody
End With
response = http.responseText
Debug.Print response
' Outputting the answer to the desired cell
Range("A1").Value = response
Set http = Nothing
End Sub