Skip to content

CallsGetIceServers#

Beta version

The functionality is in beta mode. Features are subject to change and may also work unstably. There may be additional charges for functionality in the future.
You can request access to the functionality via GREEN-API support

The method is used to get the list of servers that help the two parties of a call find a network route to each other. Audio cannot be transmitted without this list, so the method is called before sending an audio offer in the callsRtc connection.

The list is passed to WebRTC as is — in the iceServers parameter when the connection is created. You do not need to parse its content.

Request#

To get the list of servers, you have to execute a request at:

GET
{{apiUrl}}/waInstance{{idInstance}}/callsGetIceServers/{{apiTokenInstance}}

The request is executed without parameters.

For apiUrl, idInstance and apiTokenInstance request parameters, refer to Before you start section.

Response#

The response contains an array of servers in the RTCIceServer format accepted by WebRTC.

Response parameters#

Parameter Type Description
urls string | array Server address or an array of addresses
username string User name. Returned for servers that require password access
credential string Password. Returned for servers that require password access

Response body example#

[
  {
    "urls": "stun:stun.l.google.com:19302"
  },
  {
    "urls": "turn:7.777.77.77:3478?transport=udp",
    "username": "178333333:720133333333",
    "credential": "green/password="
  },
  {
    "urls": "turn:7.777.77.76:3478?transport=tcp",
    "username": "178333333:720133333333",
    "credential": "green/password="
  },
  {
    "urls": "turn:7.777.77.75:3478?transport=tcp",
    "username": "178333333:720133333333",
    "credential": "green/password="
  }
]

The actual list of servers is returned by the API and may change: the addresses, user names and passwords in the example are for illustration only. Do not store the list on your side — request it before each call.

Errors#

For a list of errors common to all methods, refer to Common errors section.

Request examples#

import requests

url = "{{apiUrl}}/waInstance{{idInstance}}/callsGetIceServers/{{apiTokenInstance}}"

payload = {}
headers = {}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/callsGetIceServers/{{apiTokenInstance}}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .append("/waInstance").append({{idInstance}})
    .append("/callsGetIceServers/")
    .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("/callsGetIceServers/")
    .append({{apiTokenInstance}});

var response = Unirest.get(requestUrl.toString())
    .header("Content-Type", "application/json")
    .asString();

System.out.println(response);