Get Details of all Calls

    To get the details of all calls, make an HTTP GET request to the Call API. The maximum number of results that can be fetched with a single API call is 20. The API will return useful parameters including call direction, from number, to number, call duration, etc. Check out the Call API documentation for all the parameters that are available.

    GET https://api.plivo.com/v1/Account/{auth_id}/Call/

    Prerequisites

    1. Sign up for a free Plivo trial account.
    2. Check out our server-side SDKs page and install the right helper based on the programming language you want to use.

    Implementation

    1. Copy the relevant code below into a text file and save it.
    2. Replace Your AUTH_ID and Your AUTH_TOKEN with the AUTH ID and AUTH TOKEN found on your Plivo dashboard.

    Code

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    
    import plivo, plivoxml
    
    auth_id = "Your AUTH_ID"
    auth_token = "Your AUTH_TOKEN"
    
    p = plivo.RestAPI(auth_id, auth_token)
    
    response = p.get_cdrs()
    print str(response)
    
    # Filtering the records
    params = {
        'end_time__gt' : "2014-12-23 11:47", # Filter out calls according to the time of completion. gte stands for greater than or equal.
        'call_direction' : "inbound", # Filter the results by call direction. The valid inputs are inbound and outbound
        'from_number' : "1111111111", # Filter the results by the number from where the call originated
        'to_number' : "2222222222", # Filter the results by the number to which the call was made
        'limit' : '2', # The number of results per page
        'offset' : '0' # The number of value items by which the results should be offset
    }
    
    response = p.get_cdrs(params)
    print str(response)
            
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    
    require 'rubygems'
    require 'plivo'
    include Plivo
    
    AUTH_ID = "Your AUTH_ID"
    AUTH_TOKEN = "Your AUTH_TOKEN"
    
    p = RestAPI.new(AUTH_ID, AUTH_TOKEN)
    
    response = p.get_cdrs()
    puts response
    
    # Filtering the records
    params = {
        'end_time__gt' => "2014-12-23 11:47", # Filter out calls according to the time of completion. gte stands for greater than or equal.
        'call_direction' => "inbound", # Filter the results by call direction. The valid inputs are inbound and outbound
        'from_number' => "1111111111", # Filter the results by the number from where the call originated
        'to_number' => "2222222222", # Filter the results by the number to which the call was made
        'limit' => '2', # The number of results per page
        'offset' => '0' # The number of value items by which the results should be offset
    }
    
    response = p.get_cdrs(params)
    puts response
            
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    
    var plivo = require('plivo');
    var p = plivo.RestAPI({
        authId: 'Your AUTH_ID',
        authToken: 'Your AUTH_TOKEN'
    });
    
    var params = { };
    p.get_cdrs(params, function (status, response) {
        console.log('Status: ', status);
        console.log('API Response:\n', response);
    });
    
    // Filtering the records
    
    var params = {
        'end_time__gt' : '2015-09-01 11:47' // Filter out calls according to the time of completion. gte stands for greater than or equal.
        'call_direction' : 'outbound', // Filter the results by call direction. The valid inputs are inbound and outbound
        'from_number' : '1111111111', // Filter the results by the number from where the call originated
        'to_number' : '2222222222', // Filter the results by the number to which the call was made
        'limit' : '10', // The number of results per page
        'offset' : '0' // The number of value items by which the results should be offset
    };
    
    p.get_cdrs(params, function (status, response) {
        console.log('Status: ', status);
        console.log('API Response:\n', response);
    });
            
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    
    <?php
        require 'vendor/autoload.php';
        use Plivo\RestAPI;
    
        $auth_id = "Your AUTH_ID";
        $auth_token = "Your AUTH_TOKEN";
        $p = new RestAPI($auth_id, $auth_token);
        $response = $p->get_cdrs();
        print_r ($response);
    
        // Filtering the records
        $params = array(
            'end_time__gt' => '2015-01-28 11:47', # Filter out calls according to the time of completion. gte stands for greater than or equal.
            'call_direction' => 'inbound', # Filter the results by call direction. The valid inputs are inbound and outbound
            'from_number' => '1111111111', # Filter the results by the number from where the call originated
            'to_number' => '2222222222', # Filter the results by the number to which the call was made
            'limit' => '2', # The number of results per page
            'offset' => '0' # The number of value items by which the results should be offset
            );
        $response = $p->get_cdrs($params);
        print_r ($response);
    ?>
            
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    
    package com.plivo.test;
    
    import java.lang.reflect.Field;
    import java.lang.reflect.Modifier;
    import java.util.LinkedHashMap;
    
    import com.plivo.helper.api.client.*;
    import com.plivo.helper.api.response.call.CDRFactory;
    import com.plivo.helper.exception.PlivoException;
    
    public class App {
        public static void main(String[] args) throws IllegalAccessException {
    
            String auth_id = "Your AUTH_ID";
            String auth_token = "Your AUTH_TOKEN";
    
            RestAPI api = new RestAPI(auth_id, auth_token, "v1");
    
            // Without filters
            LinkedHashMap<String, String> parameters = new LinkedHashMap<String, String>();
    
            try {
                CDRFactory cdr = api.getCDRs(parameters);
                System.out.println(cdr);
            } catch (PlivoException e) {
                System.out.println(e.getLocalizedMessage());
            }
    
            // Filtering the response
    
            RestAPI apis = new RestAPI(auth_id, auth_token, "v1");
    
            LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
            params.put("call_direction", "inbound");
            params.put("from_number", "1111111111");
            params.put("to_number", "2222222222");
            params.put("limit", "2");
            params.put("offset", "0");
    
            try {
                CDRFactory cdrs = apis.getCDRs(params);
                System.out.println(cdrs);
            } catch (PlivoException e) {
                System.out.println(e.getLocalizedMessage());
            }
    
        }
    }
            
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    
    using System;
    using System.Collections.Generic;
    using RestSharp;
    using Plivo.API;
    
    namespace get_details_all
    {
        class Program
        {
            static void Main(string[] args)
            {
                RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN");
    
                // Without Filters
    
                IRestResponse&lt;CDRList&gt; resp = plivo.get_cdrs(new Dictionary&lt;string, string&gt;() {});
    
                //Prints the message details
                Console.Write(resp.Content);
    
                // Filtering the response
    
                IRestResponse&lt;CDRList&gt; response = plivo.get_cdrs(new Dictionary&lt;string, string&gt;()
                {
                    { "end_time_gt", "2014-12-23 11:47" }, // Filter out calls according to the time of completion. gte stands for greater than or equal.
                    { "call_direction", "inbound" }, // Filter the results by call direction. The valid inputs are inbound and outbound
                    { "from_number","1111111111"}, // Filter the results by the number from where the call originated
                    { "to_number","2222222222"}, // Filter the results by the number to which the call was made
                    { "limit","2"}, // The number of results per page
                    { "offset","0"} // The number of value items by which the results should be offset
                });
                Console.Write(response.Content);
    
                Console.ReadLine();
            }
        }
    }
            
    
    1
    2
    3
    
    curl -i --user AUTH_ID:AUTH_TOKEN \
      https://api.plivo.com/v1/Account/{auth_id}/Call/
            
    

    Sample Response

    Without Filter

    (200, {
    u'meta': {
      u'previous': None,
      u'total_count': 37,
      u'offset': 0,
      u'limit': 20,
      u'next': u'/v1/Account/XXXXXXXXXXXXXXX/Call/?limit=2&offset=0'
    },
    u'objects': [
      {
        u'bill_duration': 0,
        u'billed_duration': 0,
        u'total_amount': u'0.00000',
        u'parent_call_uuid': None,
        u'call_direction': u'inbound',
        u'call_duration': 0,
        u'to_number': u'2222222222',
        u'total_rate': u'0.00850',
        u'from_number': u'1111111111',
        u'end_time': u'2014-12-30 21:56:33+04:00',
        u'call_uuid': u'30350d24-904d-11e4-aa47-f91d0b204d04',
        u'resource_uri': u'/v1/Account/XXXXXXXXXXXXXXX/Call/30350d24-904d-11e4-aa47-f91d0b204d04/'
      },
      {
        u'bill_duration': 0,
        u'billed_duration': 0,
        u'total_amount': u'0.00000',
        u'parent_call_uuid': None,
        u'call_direction': u'inbound',
        u'call_duration': 0,
        u'to_number': u'2222222222',
        u'total_rate': u'0.00850',
        u'from_number': u'1111111111',
        u'end_time': u'2014-12-30 21:54:09+04:00',
        u'call_uuid': u'da84966a-904c-11e4-bdae-b559cbfe39b9',
        u'resource_uri': u'/v1/Account/XXXXXXXXXXXXXXX/Call/da84966a-904c-11e4-bdae-b559cbfe39b9/'
      }
    ]
    )
    

    With Filter

    (200, {
          u'meta': {
              u'previous': None,
              u'total_count': 2,
              u'offset': 0,
              u'limit': 10,
              u'next': None
          },
          u'objects': [
            {
                u'bill_duration': 18,
                u'billed_duration': 60,
                u'total_amount': u'0.00850',
                u'parent_call_uuid': None,
                u'call_direction': u'inbound',
                u'call_duration': 18,
                u'to_number': u'2222222222',
                u'total_rate': u'0.00850',
                u'from_number': u'1111111111',
                u'end_time': u'2014-12-30 16:00:50+04:00',
                u'call_uuid': u'74430d86-901b-11e4-9a96-71f618784e1e',
                u'resource_uri': u'/v1/Account/XXXXXXXXXXXXXXX/Call/74430d86-901b-11e4-9a96-71f618784e1e/'
            },
            {
              u'bill_duration': 13,
              u'billed_duration': 60,
              u'total_amount': u'0.00850',
              u'parent_call_uuid': None,
              u'call_direction': u'inbound',
              u'call_duration': 13,
              u'to_number': u'2222222222',
              u'total_rate': u'0.00850',
              u'from_number': u'1111111111',
              u'end_time': u'2014-12-30 15:59:16+04:00',
              u'call_uuid': u'3f2192a8-901b-11e4-93ac-c374cdd23d80',
              u'resource_uri': u'/v1/Account/XXXXXXXXXXXXXXX/Call/3f2192a8-901b-11e4-93ac-c374cdd23d80/'
            }
        ]
    )
    

    Next Step

    Learn how to Get Details of a Single Call

    1. Make an Outbound Call
    2. Play a Text-to-speech Message
    3. Connect Call to a Second Person
    4. Greet Caller by Name
    5. Play MP3/WAV Audio to Caller
    6. Hangup Using API
    7. Receive Incoming Call
    8. Forward Incoming Call
    9. Record Using API
    10. Screen Incoming Call
    11. Reject incoming call
    12. Get Details of all Calls
    13. Get Details of a single Call
    14. Get Details of Live Calls
    15. Build an IVR Phone Menu
    16. Conference Call
    17. Call Forward
    18. SIP Endpoint (Direct-Dial)