GetContacts#
The method is used to getting a list of the current account contacts.
Updating information about contacts can take up to 5 minutes.
If an empty data array is received - repeat the method call.
Request#
To get contacts, you have to execute a request at:
 GET    
 {{apiUrl}}/waInstance{{idInstance}}/getContacts/{{apiTokenInstance}}
For apiUrl, idInstance and apiTokenInstance request parameters, refer to Before you start section.
URL request parameters#
| Parameter | Type | Mandatory | Description | 
|---|---|---|---|
group |  boolean | No | Specifying group=true only show groups |  
Specifying group=false will only show personal chats |  |||
| If the parameter is missing, the full list of contacts is displayed | |||
count |  integer | No | When specifying the number count={{number}}, the specified number of contacts is displayed |  
| If there are fewer contacts than the specified number, then all contacts that match the query are displayed | |||
| If the parameter is missing, the full list of contacts is displayed | 
Request examples with parameters#
Get a list of groups for the current account:
 GET    
 {{apiUrl}}/waInstance{{idInstance}}/getContacts/{{apiTokenInstance}}?group=true
Get a list of personal chats of the current account in a given quantity:
 GET    
 {{apiUrl}}/waInstance{{idInstance}}/getContacts/{{apiTokenInstance}}?group=false&count={{number}}  
Response#
Response parameters#
| Parameter | Type | Description | 
|---|---|---|
id |  string | User or group chat Id | 
name |  string | Contact name. Possible values: | 
| 1) If there is incoming correspondence/reactions from the account, then we get the name from the WhatsApp profile | ||
| 2) If there is no incoming correspondence/reactions from the account, then we get an empty line | ||
contactName |  string | Contact name from the phone book | 
type |  string | Contact type. Possible values: | 
user - contact belongs to a user |  ||
group - contact is a group chat |  
Response body example#
[
    {
        "id": "79876543210@c.us",
        "name": "John Petrov",
        "contactName": "John Petorov Work",
        "type": "user"
    },
    {
        "id": "79001234567@c.us",
        "name": "Lyusya Sidorova",
        "contactName": "Liusya Sidorova Sewing Circle",
        "type": "user"
    },
    {
        "id": "79001234569-1479621234@g.us",
        "name": "My group",  
        "type": "group"
    }
]
GetContacts errors#
For a list of errors common to all methods, refer to Common errors section
| HTTP code | Error description | Possible solutions | 
|---|---|---|
| 200 | The getContacts method returns an empty array [] |  1. Rescan the QR code.  2. Contact technical support.  |  
Request examples#
import requests
url = "{{apiUrl}}/waInstance{{idInstance}}/getContacts/{{apiTokenInstance}}"
payload = {}
headers= {}
response = requests.request("GET", url, headers=headers, data = payload)
print(response.text.encode('utf8'))
curl --location '{{APIUrl}}/waInstance{{idInstance}}/getContacts/{{apiTokenInstance}}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .append("/waInstance").append({{idInstance}})
    .append("/getContacts/")
    .append({{apiTokenInstance}});
var response = restTemplate.exchange(requestUrl.toString(), HttpMethod.GET, null, String.class);
System.out.println(response);
var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .append("/waInstance").append({{idInstance}})
    .append("/getContacts/")
    .append({{apiTokenInstance}});
var response = Unirest.get(requestUrl.toString())
    .header("Content-Type", "application/json")
    .asString();
System.out.println(response);
Sub GetContacts()
    Dim url 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}}/GetContacts/{{apiTokenInstance}}"
    Set http = CreateObject("MSXML2.XMLHTTP")
    http.Open "GET", url, False
    http.Send
    response = http.responseText
    Debug.Print response
    ' Outputting the answer to the desired cell
    Range("A1").Value = response
    Set http = Nothing
End Sub