AccAPI - API Documentation

About

logo 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Ş

Usage

API will return errors like following:

 
AخA
{
  "error": "401 : Unauthorized"
}

Getting Account Data

Getting Voip Authentication Info

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"
}

Getting Balance

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"
}

Getting Rate For A CLD

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"
}

Getting Rate List

POST following data to https://api.roitel.com.tr/ratelist:

 
xxxxxxxxxx
{
  "username":"WEB_USERNAME", 
  "password":"WEB_PASSWORD"
}

Optional Parameters:

ParameterTypeDefaultDescription
offsetint0Skip fist offset Rates
limitint5000Return only limit Rates(max 5000)
prefixstringReturn 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
    },
    ...
 ]
}

Getting Registration Status

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"
}

Getting CDRs

POST following data to https://api.roitel.com.tr/cdrs:

 
xxxxxxxxxx
{
  "username":"WEB_USERNAME", 
  "password":"WEB_PASSWORD"
}

Optional Parameters:

ParameterTypeDefaultDescription
offsetint0Skip fist offset CDRs
limitint5000Return only limit CDRs(max 5000)
i_cdrintReturn only specific CDR with this id.
start_timeintDate 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_timeintNowDate in Unix Time to fetch CDRs until
clistringFetch CDRs with this CLI
cldstringFetch CDRs with this CLD
cdr_typestringnon_zero_and_errorsType of CDRs to fetch.

CDR Types:

NameDescription
non_zero_and_errorsReturn only non-zero duration and errors CDRs
non_zeroReturn only non-zero duration CDRs
allReturn all CDRs
completeReturn only CDRs of completed calls
incompleteReturn only CDRs of incomplete calls
errorsReturn 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)"
    }
  ]
}

Callback

Making Callback Request

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:

ParameterTypeDefaultDescription
max_durationintDrop first leg call after this amount of seconds
call_atintDate in Unix Time when to initialize call

You'll get a response like following on success

 
xxxxxxxxxx
{
  "request_id": 207180
}

Get Callback Status

POST following data to https://api.roitel.com.tr/cbstatus:

 
xxxxxxxxxx
{
  "username":"WEB_USERNAME", 
  "password":"WEB_PASSWORD",
  "request_id": 207180 
}

Optional Parameters:

ParameterTypeDefaultDescription
get_cdrsboolfalseGet 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"
    }
  ]
}

Cancel Callback Request

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
}

Follow Me

Getting FollowMe Options

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
}

Updating FollowMe Options

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:

NameDescription
1Always
2On Unavailable
3Off
4On Busy
5On No Answer

You'll get a response like following on success

 
xxxxxxxxxx
{
  "mode_name": "On Unavailable",
  "timeout": 10,
  "mode_id": 2
}

Getting List of FollowMe Entries

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
    }
  ]
}

Adding new FollowMe Entry

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:

NameDescription
firstAdd as first entry
lastAdd as last entry
#A numeric entry for preference

You'll get a response like following on success

 
xxxxxxxxxx
{
  "entry_id": 5120
}

Updating FollowMe Entry

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:

NameDescription
firstAdd as first entry
lastAdd as last entry
#A numeric entry for preference
upMove upper order
downMove lower order

You'll get a response like following on success

 
xxxxxxxxxx
{
  "success": true
}

Deleting FollowMe Entry

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
}

Smart Dial

Getting List of Smart Dial Entries

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"
    }
  ]
}

Adding new Smart Dial Entry

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
}

Updating Smart Dial Entry

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
}

Deleting Smart Dial Entry

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
}

Hot Dial

Getting List of Hot Dial Entries

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"
    }
  ]
}

Adding new Hot Dial Entry

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
}

Updating Hot Dial Entry

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
}

Deleting Hot Dial Entry

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
}

Example Codes

CURL

 
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"

PHP

 
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;
}

Python

 
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"))

C

 
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);

Java

 
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(); 

GO

 
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))
}

Objective-C

 
xxxxxxxxxx
#import <Foundation/Foundation.h>
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];

NodeJS

 
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();

Ruby

 
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

C

 
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);