This document shows how to call AccApi. AccApi is developed by Eurotel AŞ. By using AccApi you can get information about your VOIP Account at Roitel Telekomunikasyon AŞ
API will return errors like following:
AخA{
"error": "401 : Unauthorized"
}
POST
following data to https://api.roitel.com.tr/auth
:
xxxxxxxxxx
{
"username":"WEB_USERNAME",
"password":"WEB_PASSWORD"
}
You'll get a response like following on success
xxxxxxxxxx
{
"balance": -27.4045,
"currency": "TRY",
"voip_username": "VOIP_USERNAME",
"voip_password": "VOIP_PASSWORD"
}
POST
following data to https://api.roitel.com.tr/balance
:
xxxxxxxxxx
{
"username":"WEB_USERNAME",
"password":"WEB_PASSWORD"
}
You'll get a response like following on success
xxxxxxxxxx
{
"balance": -27.4045,
"currency": "TRY"
}
POST
following data to https://api.roitel.com.tr/rate
:
xxxxxxxxxx
{
"username":"WEB_USERNAME",
"password":"WEB_PASSWORD",
"cld":"1902112121212"
}
You'll get a response like following on success
xxxxxxxxxx
{
"rate": 0.1234,
"country": "CANADA",
"description": "NPA 902 NOVA SCOTIA",
"currency": "TRY"
}
POST
following data to https://api.roitel.com.tr/ratelist
:
xxxxxxxxxx
{
"username":"WEB_USERNAME",
"password":"WEB_PASSWORD"
}
Optional Parameters:
Parameter | Type | Default | Description |
---|---|---|---|
offset | int | 0 | Skip fist offset Rates |
limit | int | 5000 | Return only limit Rates(max 5000) |
prefix | string | Return rates with prefix(You can use % for matchings) |
You'll get a response like following on success
xxxxxxxxxx
{
"currency": "TRY",
"data": [
{
"country": "CANADA",
"description": "NPA 204 MANITOBA",
"prefix": "1204",
"rate": 0.1234
},
{
"country": "USA",
"description": "OTHER",
"prefix": "1",
"rate": 0.1234
},
]
}
POST
following data to https://api.roitel.com.tr/regstat
:
xxxxxxxxxx
{
"username":"WEB_USERNAME",
"password":"WEB_PASSWORD"
}
You'll get a response like following on success
xxxxxxxxxx
{
"balance": "Linphone/3.10.2 (belle-sip/1.5.0)",
"contact": "sip:9085012345677@78.187.1.1:63439;transport=udp",
"expires": "09:40:35.000 GMT Sat Dec 17 2016"
}
POST
following data to https://api.roitel.com.tr/cdrs
:
xxxxxxxxxx
{
"username":"WEB_USERNAME",
"password":"WEB_PASSWORD"
}
Optional Parameters:
Parameter | Type | Default | Description |
---|---|---|---|
offset | int | 0 | Skip fist offset CDRs |
limit | int | 5000 | Return only limit CDRs(max 5000) |
i_cdr | int | Return only specific CDR with this id. | |
start_time | int | Date in Unix Time to fetch CDRs from, for example for date "Tue, 07 Mar 2017 12:11:00 GMT" send 1488888660. If not send, CDRs for last hour is returned. | |
end_time | int | Now | Date in Unix Time to fetch CDRs until |
cli | string | Fetch CDRs with this CLI | |
cld | string | Fetch CDRs with this CLD | |
cdr_type | string | non_zero_and_errors | Type of CDRs to fetch. |
CDR Types:
Name | Description |
---|---|
non_zero_and_errors | Return only non-zero duration and errors CDRs |
non_zero | Return only non-zero duration CDRs |
all | Return all CDRs |
complete | Return only CDRs of completed calls |
incomplete | Return only CDRs of incomplete calls |
errors | Return CDRs with error |
You'll get a response like following on success
xxxxxxxxxx
{
"cdrs": [
{
"billed_duration": 2,
"call_id": "HYVcZs9NzM",
"cld": "B003905441234567",
"cli": "08501234567",
"connect_time": 0,
"cost": 0.01234567,
"country": "TURKIYE",
"delay": 7,
"description": "VODAFONE",
"disconnect_time": 0,
"duration": 2,
"i_call": 414031709,
"i_cdr": 401486564,
"pdd1xx": 2.919146683,
"prefix": "B003",
"release_source": "callee",
"remote_ip": "78.187.1.1",
"result": 0,
"user_agent": "Linphone/3.10.2 (belle-sip/1.5.0)"
}
]
}
POST
following data to https://api.roitel.com.tr/cb
:
xxxxxxxxxx
{
"username":"WEB_USERNAME",
"password":"WEB_PASSWORD",
"cld_first": "905441234567",
"cld_second": "902161234567"
}
Optional Parameters:
Parameter | Type | Default | Description |
---|---|---|---|
max_duration | int | Drop first leg call after this amount of seconds | |
call_at | int | Date in Unix Time when to initialize call |
You'll get a response like following on success
xxxxxxxxxx
{
"request_id": 207180
}
POST
following data to https://api.roitel.com.tr/cbstatus
:
xxxxxxxxxx
{
"username":"WEB_USERNAME",
"password":"WEB_PASSWORD",
"request_id": 207180
}
Optional Parameters:
Parameter | Type | Default | Description |
---|---|---|---|
get_cdrs | bool | false | Get CDRs of callback |
You'll get a response like following on success if you also set get_cdrs=true
in your request (otherwise cdrs
field will be an empty array):
x
{
"call_result": "Successful",
"call_status": "Finished",
"cdrs": [
{
"accessibility_cost": 0,
"billed_duration": 10,
"cld": "B003905441234567",
"cli": "05441234567",
"connect_time": "2016-12-17T16:48:29Z",
"cost": 0.01234567,
"delay": 7,
"disconnect_time": "2016-12-17T16:48:39Z",
"duration": 10,
"plan_duration": 0,
"release_source": "caller",
"result": 0,
"role": "First Call Leg",
"setup_time": "2016-12-17T16:48:23Z"
},
{
"accessibility_cost": 0,
"billed_duration": 3,
"cld": "902161234567",
"cli": "02161234567",
"connect_time": "2016-12-17T16:48:36Z",
"cost": 0,
"delay": 6,
"disconnect_time": "2016-12-17T16:48:39Z",
"duration": 3,
"plan_duration": 0,
"release_source": "callee",
"result": 0,
"role": "Second Call Leg",
"setup_time": "2016-12-17T16:48:30Z"
}
]
}
POST
following data to https://api.roitel.com.tr/cbcancel
:
xxxxxxxxxx
{
"username":"WEB_USERNAME",
"password":"WEB_PASSWORD",
"request_id": 207180
}
You'll get a response like following on success
xxxxxxxxxx
{
"success": true
}
POST
following data to https://api.roitel.com.tr/fmoptions
:
xxxxxxxxxx
{
"username":"WEB_USERNAME",
"password":"WEB_PASSWORD"
}
You'll get a response like following on success
xxxxxxxxxx
{
"mode_name": "On Unavailable",
"timeout": 10,
"mode_id": 2
}
POST
following data to https://api.roitel.com.tr/fmsetoptions
:
xxxxxxxxxx
{
"username":"WEB_USERNAME",
"password":"WEB_PASSWORD",
"timeout": 10,
"mode_id": 2
}
Both timeout
(seconds) and mode_id
are optional parameters.
Mode Types:
Name | Description |
---|---|
1 | Always |
2 | On Unavailable |
3 | Off |
4 | On Busy |
5 | On No Answer |
You'll get a response like following on success
xxxxxxxxxx
{
"mode_name": "On Unavailable",
"timeout": 10,
"mode_id": 2
}
POST
following data to https://api.roitel.com.tr/fmlist
:
xxxxxxxxxx
{
"username":"WEB_USERNAME",
"password":"WEB_PASSWORD"
}
You'll get a response like following on success
xxxxxxxxxx
{
"data": [
{
"cld": "905441234567",
"description": "test",
"entry_id": 5118,
"preference": 1,
"timeout": 20
},
{
"cld": "902161234567",
"description": "test2",
"entry_id": 5119,
"preference": 2,
"timeout": 30
}
]
}
POST
following data to https://api.roitel.com.tr/fmadd
:
xxxxxxxxxx
{
"username":"WEB_USERNAME",
"password":"WEB_PASSWORD",
"timeout": 10,
"cld":"902161234567",
"preference":"last",
"description":"test2"
}
preference
and description
are optional parameters.
Preference Types:
Name | Description |
---|---|
first | Add as first entry |
last | Add as last entry |
# | A numeric entry for preference |
You'll get a response like following on success
xxxxxxxxxx
{
"entry_id": 5120
}
POST
following data to https://api.roitel.com.tr/fmupdate
:
xxxxxxxxxx
{
"username":"WEB_USERNAME",
"password":"WEB_PASSWORD",
"entry_id": 5120,
"timeout": 20,
"cld":"905441234567",
"preference":"last",
"description":"test2"
}
cld
, preference
and description
are optional parameters.
Preference Types:
Name | Description |
---|---|
first | Add as first entry |
last | Add as last entry |
# | A numeric entry for preference |
up | Move upper order |
down | Move lower order |
You'll get a response like following on success
xxxxxxxxxx
{
"success": true
}
POST
following data to https://api.roitel.com.tr/fmdelete
:
xxxxxxxxxx
{
"username":"WEB_USERNAME",
"password":"WEB_PASSWORD",
"entry_id": 5120
}
You'll get a response like following on success
xxxxxxxxxx
{
"success": true
}
POST
following data to https://api.roitel.com.tr/sdlist
:
xxxxxxxxxx
{
"username":"WEB_USERNAME",
"password":"WEB_PASSWORD"
}
You'll get a response like following on success
xxxxxxxxxx
{
"data": [
{
"did": "905441234567",
"destination": "902161234567",
"description": "test"
}
]
}
POST
following data to https://api.roitel.com.tr/sdadd
:
xxxxxxxxxx
{
"username":"WEB_USERNAME",
"password":"WEB_PASSWORD",
"did": "905441234567",
"destination": "902161234567",
"description": "test"
}
description
is optional parameter.
You'll get a response like following on success
xxxxxxxxxx
{
"success": true
}
POST
following data to https://api.roitel.com.tr/sdupdate
:
xxxxxxxxxx
{
"username":"WEB_USERNAME",
"password":"WEB_PASSWORD",
"did": "905441234567",
"destination": "902161234567",
"description": "test"
}
destination
and description
are optional parameters.
You'll get a response like following on success
xxxxxxxxxx
{
"success": true
}
POST
following data to https://api.roitel.com.tr/sddelete
:
xxxxxxxxxx
{
"username":"WEB_USERNAME",
"password":"WEB_PASSWORD",
"did": "905441234567"
}
You'll get a response like following on success
xxxxxxxxxx
{
"success": true
}
POST
following data to https://api.roitel.com.tr/hdlist
:
xxxxxxxxxx
{
"username":"WEB_USERNAME",
"password":"WEB_PASSWORD"
}
You'll get a response like following on success
xxxxxxxxxx
{
"data": [
{
"hot_key": "905441234567",
"destination": "902161234567",
"description": "test"
}
]
}
POST
following data to https://api.roitel.com.tr/hdadd
:
xxxxxxxxxx
{
"username":"WEB_USERNAME",
"password":"WEB_PASSWORD",
"hot_key": "905441234567",
"destination": "902161234567",
"description": "test"
}
description
is optional parameter.
You'll get a response like following on success
xxxxxxxxxx
{
"success": true
}
POST
following data to https://api.roitel.com.tr/hdupdate
:
xxxxxxxxxx
{
"username":"WEB_USERNAME",
"password":"WEB_PASSWORD",
"hot_key": "905441234567",
"destination": "902161234567"
}
You'll get a response like following on success
xxxxxxxxxx
{
"success": true
}
POST
following data to https://api.roitel.com.tr/hddelete
:
xxxxxxxxxx
{
"username":"WEB_USERNAME",
"password":"WEB_PASSWORD",
"hot_key": "905441234567"
}
You'll get a response like following on success
xxxxxxxxxx
{
"success": true
}
xxxxxxxxxx
curl -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{"username":"WEB_USER", "password":"WEB_PASSWORD"}' "https://api.roitel.com.tr/auth"
x<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.roitel.com.tr/auth",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"username\":\"WEB_USER\", \"password\":\"WEB_PASSWORD\"}",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
xxxxxxxxxx
import http.client
conn = http.client.HTTPSConnection("api.roitel.com.tr")
payload = "{\"username\":\"WEB_USER\", \"password\":\"WEB_PASSWORD\"}"
headers = {
'content-type': "application/json",
'cache-control': "no-cache"
}
conn.request("POST", "/auth", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
xxxxxxxxxx
var client = new RestClient("https://api.roitel.com.tr/auth");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json",
"{\"username\":\"WEB_USER\", \"password\":\"WEB_PASSWORD\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
xxxxxxxxxx
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"username\":\"WEB_USER\", \"password\":\"WEB_PASSWORD\"}");
Request request = new Request.Builder()
.url("https://api.roitel.com.tr/auth")
.post(body)
.addHeader("content-type", "application/json")
.addHeader("cache-control", "no-cache")
.build();
Response response = client.newCall(request).execute();
xxxxxxxxxx
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.roitel.com.tr/auth"
payload := strings.NewReader("{\"username\":\"WEB_USER\", \"password\":\"WEB_PASSWORD\"}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
xxxxxxxxxx
NSDictionary *headers = @{ @"content-type": @"application/json",
@"cache-control": @"no-cache" };
NSDictionary *parameters = @{ @"username": @"WEB_USER",
@"password": @"WEB_PASSWORD" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.roitel.com.tr/auth"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
xxxxxxxxxx
var http = require("https");
var options = {
"method": "POST",
"hostname": "api.roitel.com.tr",
"port": null,
"path": "/auth",
"headers": {
"content-type": "application/json",
"cache-control": "no-cache"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ username: 'WEB_USER', password: 'WEB_PASSWORD' }));
req.end();
xxxxxxxxxx
require 'uri'
require 'net/http'
url = URI("https://api.roitel.com.tr/auth")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'
request.body = "{\"username\":\"WEB_USER\", \"password\":\"WEB_PASSWORD\"}"
response = http.request(request)
puts response.read_body
xxxxxxxxxx
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.roitel.com.tr/auth");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "cache-control: no-cache");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\"username\":\"WEB_USER\", \"password\":\"WEB_PASSWORD\"}");
CURLcode ret = curl_easy_perform(hnd);