Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

REQUEST

This API is used to get the Call Details Report. In Portal, It is the query data action then display on the web. This API allows many arguments and filter criteria. It will be described in next part.

The structure of API as below:

GET

localhost:8888

Required Arguments

Required Argument is the parameter that you have to put into API to run it. The API can't be run without Required Argument. The list of Required Argument of this API is described as below:

ParameterDescription
start_timeSearch within the specified time. It allows negative values (negative for last 15 min or 1 hour or 24 hours and if possitive then need to give end date). This parameter is the start time of the specified time. The format of Start Time is Epoch timestamp. To convert from date time to Epoch Timestamp, please go to https://www.epochconverter.com/

Optional Arguments

Optional Argument is the parameter that you can put into API to run it. The API can be run without Requirement Argument. The list of Optional Argument of this API is described as below:

Panel

On this page:

Table of Contents

ParameterDescription
end_timeThis parameter is the end time of the specified time to search CDR. The format of Endtime is Epoch timestamp. To convert from date time to Epoch Timestamp, please go to https://www.epochconverter.com/. If you fill out the end time, the API will query data from start time to end time. If you don't fill in the end time, the API will query data from start time to the current time.
from, count

Printing range. Default: print everything.

From: Select the page that you want to print. If from=3, it will print from page 3 to the end.

Count: Select the total records display per page. If there are 53 records and we set Count = 10, it will print to 6 pages: 5 pages have 10 records and 1 page have 3 records.

format

Select the format of output file. There are three types of format:

csv: CSV file ( default ).

json: Output is json file.

cdr_json: CDR lines, wrapped into json list.

fieldSelect the list of fields to print. Comma-separated list of fields to print. Default: print all fields
human_readable

Using human-readable values. The default is 0.

If set human_readable=0 you have to provide ids of trunks , rate, type ... into API.

If set human_readable=1 converts them into their names and put into API.

print_only_amountSelect amount records to print. If you found 100 records, but you set 50 for print_only_amount, it prints 50 records only.

Search filter

This is the parameter to filter data. The list of filter criteria is described as below:

ParameterDescription
release_causeFilter by release cause. We input the ID of release cause into API and the format of this parameter is the integer. To know about the ID, please refer Global Route Error.
orig_codeFilter by the Origination code (integer). It is Country Name, Code Name and Code of the place where make the call. Please refer Rate Table for further information.
term_codeFilter by the Termination code (integer). It is Country Name, Code Name and Code of the place where receiving the call. Please refer Rate Table for further information.
ingress_idFilter by ID of Ingress Trunk (integer). Login to V6 → Go to Routing → Trunks → Get the ID of trunk.
egress_idFilter by ID of Egress Trunk (integer). Login to V6 → Go to Routing → Trunks → Get the ID of trunk.
orig_dest_host Filter by originating destination hostname (string).
source_numberFilter by Originating source number (string).
dest_numberFilter by Originating destination numbers (string).
term_source_numberFilter by Termination source number (string).
term_dest_numberFilter by Termination destination number (string).
orig_call_idFilter by Origination call ID (string)
term_call_idFilter by Termination call ID (string)
routing_digitsFilter by Routing Number (string)
ingress_rcauseFilter by Release Cause on Ingress Trunk (string). Please refer Default Fail Over Rule for further information.
egress_rcauseFilter by Release Cause on Egress Trunk (string). Please refer Default Fail Over Rule for further information.
is_final_callSet 1 to show final call only. Set 2 to show not final call only and default is show all.
non_zeroSet 1 to show non zero call only . Set 2 to show zero call only and default is show all. Zero call is the call with the duration time is 0.

duration_min

duration_max

Filter by the duration time of call (integer). You have to set the Duration Min and Duration Max. The call has duration time belong to this period will be shown.

cost_min

cost_max

Filter by the cost of call (floating point). You have to set the Cost Min and Cost Max. The call has cost in range will be shown.
call_tzFilter by call timezone in minutes (integer).
only_authorizedSet 1 to show authorized call only. Set 2 to show unauthorized call only and default is show all.

HEADER

The request requires you given the Token of User who have permission to see the CDR. To get the Token, please refer Authenticate User for more details.

Code Block
{
	"Authorization": "Token <CDR token from login>"
}

 

If you call API without header, the system will return the message as below:

Code Block
{
  	"error_type": "unauthenticated_error",
   	"success": false,
   	"error":    {
      	"message": "No header X-Auth-Token present",
      	"code": 110,
      	"reason": "auth_token_not_provided"
   	}
}

METHOD TO QUERY

This API is queried locally. First you have to ssh to the internal server then call API at local to query data.

The method of Query is described as below:

Code Block
Curl \
-H "Authorization: Token <CDR token from login>" 
"localhost:8888?start_time=<-negative for last 15min or 1 hour or 24hours and if possitive then need to give end date>&<optional1>=<value>&<optional2>=<value>&<optional3>=<value>&<Search filter1>=<value>&<Search filter2>=<value>&<Search filter3>=<value>"

EXAMPLE

We will know more about the API through the example below:

Call API to get CRD from 02 March 2018 to 08 March 2018 and call go through the Ingress Trunk ID is 1,2,3 and Ingress ID is 1,2,3 and Origination Code is 1. Print field 1,2,3,4 on the result from page 0 and 10 records per page. Download the result as CSV file.

Code Block
Curl \
-H "Authorization: Token <Token>" 
"localhost:8888?start_time=1519948800&end_time=1520510399&from=0&count=10&format=csv&field=1,2,3,4&ingress_id=1,2,3&egress_id=1,2,3,4&orig_code=1"

...