GetWaSettings#
The method is used to get information about the WhatsApp account
Request#
To get information about the WhatsApp account you have to execute a request at:
GET
{{apiUrl}}/waInstance{{idInstance}}/getWaSettings/{{apiTokenInstance}}
For apiUrl, idInstance and apiTokenInstance request parameters, please refer to Before you start section.
Response#
Response parameters#
| Parameter | Type | Description |
|---|---|---|
avatar | string | Whatsapp account avatar url |
base64Avatar | string | Avatar in base64 format |
chatId | string | lid of the currently logged-in account. If the instance is not authorized this field returns an empty string. |
phone | string | Whatsapp account number |
historySyncProgress | integer | Percentage of chat history downloaded on the instance |
stateInstance | string | Instance state. Have variants: |
notAuthorized - Instance is not authorized. For instance authorization refer to Before you start section | ||
authorized - Instance is authorized | ||
blocked - Instance banned | ||
sleepMode - Status is out of date. Instance is in sleep mode. The state is possible when the phone is switched off. After the phone is switched on, it may take up to 5 minutes for the instance state to be changed to authorized. | ||
starting - The instance is in the process of starting up (service mode). An instance, server, or instance in maintenance mode is rebooting. It may take up to 5 minutes for the instance state to be set to authorized. | ||
yellowCard - Message sending has been temporarily suspended on this instance due to spam activity. Messages sent after receiving the status are stored in the queue to be sent for 24 hours | ||
deviceId | string | Device ID |
logoutProcess | boolean | The instance data cleanup process is running. Authorization to the instance is not possible. Please wait for the process to complete |
If the instance has the status
notAuthorized,blocked, orstarting, the fieldsavatar,chatId,phone,deviceIdwill be empty.
Response body example#
{
"stateInstance": "authorized",
"deviceId": "0123456789:26@s.whatsapp.net",
"chatId": "209723420885003@lid",
"phone": "0123456789",
"historySyncProgress": 100,
"avatar": "https://pps.whatsapp.net/v/t61.24694-24/362901986_992130525270289_51888663873132080_n.jpg?stp=dst-jpg_s96x96&ccb=11-4&oh=01_AdQyzknkSczbj9GISmMOEgba4hnYLqqtAoLaLpT5GvJ5wQ&oe=64F40542&_nc_cat=106",
"base64Avatar": "data:image/png;base64,/9j/4 ... AA/9k="
}
Example response body when running the data cleaning process on an instance#
{
"stateInstance": "notAuthorized",
"logoutProcess": true,
"avatar": ""
}
Errors GetWaSettings#
For a list of errors common to all methods, refer to Common errors section
Request examples#
import requests
#The apiUrl, idInstance and apiTokenInstance values are available in console, double brackets must be removed
url = "{{apiUrl}}/waInstance{{idInstance}}/getWaSettings/{{apiTokenInstance}}"
payload = {}
headers = {}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text.encode('utf8'))
<?php
//The apiUrl, idInstance and apiTokenInstance values are available in console, double brackets must be removed
$url = "{{apiUrl}}/waInstance{{idInstance}}/getWaSettings/{{apiTokenInstance}}";
$options = array(
'http' => array(
'header' => "Content-Type: application/json\r\n",
'method' => 'GET'
)
);
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
echo $response;
?>
curl --location '{{apiUrl}}/waInstance{{idInstance}}/getWaSettings/{{apiTokenInstance}}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
.append({{apiUrl}})
.append("/waInstance").append({{idInstance}})
.append("/getWaSettings/")
.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("/getWaSettings/")
.append({{apiTokenInstance}});
var response = Unirest.get(requestUrl.toString())
.header("Content-Type", "application/json")
.asString();
System.out.println(response);
Sub GetWaSettings()
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}}/getWaSettings/{{apiTokenInstance}}"
Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
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
program GetWaSettings;
{$APPTYPE CONSOLE}
uses
System.SysUtils,
System.Classes, System.Net.HttpClient, System.Net.URLClient, System.Net.HttpClientComponent;
var
HttpClient: TNetHTTPClient;
RequestHeaders: TNetHeaders;
Response: IHTTPResponse;
EndpointURL, ID_INSTANCE, API_TOKEN_INSTANCE: string;
begin
ID_INSTANCE := '110100001';
API_TOKEN_INSTANCE := 'd75b3a66374942c5b3c019c698abc2067e151558acbd451234';
EndpointURL := 'https://api.green-api.com/waInstance' + ID_INSTANCE + '/getWaSettings/' + API_TOKEN_INSTANCE;
HttpClient := TNetHTTPClient.Create(nil);
RequestHeaders := [
TNetHeader.Create('Content-Type', 'application/json')
];
try
Response := HTTPClient.Get(EndpointURL, nil, RequestHeaders);
if Response.StatusCode = 200 then
Writeln('[Response]: ' + Response.ContentAsString)
else
Writeln('[ERROR ' + IntToStr(Response.StatusCode) + ']:' + Response.StatusText + '' + Response.ContentAsString);
readln;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
HttpClient.Free;
end.