GetWaSettings#
The method is aimed 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 |
phone | string | Whatsapp account number |
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 - Sending messages has been partially or completely suspended on the account due to spamming activity. Messages sent after receiving the status are stored in the queue to be sent for 24 hours. To continue running the instance, you need to do a reboot of the instance | ||
deviceId | string | Device ID |
If the instance has the status
notAuthorized
,blocked
, orstarting
, the fieldsavatar
,phone
,deviceId
will be empty.
Response body example#
{
"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",
"phone": "0123456789",
"stateInstance": "authorized",
"deviceId": "0123456789:26@s.whatsapp.net"
}
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.