First you need to generate API key from your buyer portal and copy the API key.


Sample Code to Download tariff (the tariff download that is output in CSV):


<?php

// my login in TCXC
$api_login ="Enter Buyer Username";

//my API key
$api_key = 'PASTE API KEY HERE';

// initialising CURL
$ch = curl_init();

//controller is a script name, so in case lookup.php controller is lookup
$controller = "accounts";

//unix timestamp to ensure that signature will be valid temporary
$ts = time();

//compose signature concatenating controller api_key api_login and unix timestamp
$signature = hash( 'sha256', $controller .  $api_key   . $api_login  . $ts);

$params = array(
                'ts' => $ts,  //provide TS
                'signature' => $signature,
                'api_login' => $api_login,
                'webapi'    => 1,
                'download'  => 584
                );


//query against api. URL
curl_setopt($ch, CURLOPT_URL,"https://members.telecomsxchange.com/$controller.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
http_build_query($params));
//curl_setopt($ch, CURLOPT_VERBOSE, true);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);

//analyze JSON output
echo "server_output:$server_output";


?>



If you need another i_tariff it may be discovered through Market View API call i_tariff field of the rates entry, here is an example:



# php marketview_lookup.php

server_output:{

    "status": "success",

    "rates": [

        {

            "prefix": "380",

            "vendor_name": "testseller",

            "connection_name": "testnew_route1",

            "i_tariff": "181",

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^