openapi: 3.0.0
info:
  title: Statistics
  description: Everything about account statistics
servers:
  - url: https://rest.clicksend.com
components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
  schemas:
    currency:
      type: object
      description: The parameters related to currency.
      properties:
        currency_name_short:
          type: string
          description: >-
            The currency used for the sender in three-letter format (e.g. USD,
            EUR, AUD, NZD, etc).
          example: AUD
        currency_prefix_d:
          type: string
          description: >-
            The symbol used to indicate the currency of the sender (e.g. $ , €,
            etc).
          example: $
        currency_prefix_c:
          type: string
          description: The currency basic unit (e.g. cents).
          example: c
        currency_name_long:
          type: string
          description: The full name of the currency.
          example: Australian Dollars
    view-voice-statistics:
      type: object
      properties:
        http_code:
          type: integer
          description: The HTTP status code of the response.
          example: 200
        response_code:
          type: string
          description: The response code indicating the status of the operation.
          example: SUCCESS
        response_msg:
          type: string
          description: A message describing the outcome of the operation.
          example: Here are your statistics.
        data:
          type: object
          properties:
            total:
              type: object
              properties:
                outbound:
                  type: object
                  properties:
                    count:
                      type: integer
                      description: The total count of outbound calls.
                      example: 1
                    price:
                      type: string
                      description: The total price of outbound calls.
                      example: 0
                bounced:
                  type: object
                  properties:
                    count:
                      type: integer
                      description: The total count of bounced calls.
                      example: 0
            stats:
              type: array
              items:
                type: object
                properties:
                  date:
                    type: number
                    description: The date.
                    example: 1441065600
                  outbound:
                    type: object
                    properties:
                      count:
                        type: integer
                        description: The count of outbound calls.
                        example: 0
                      price:
                        type: number
                        description: The price of outbound calls.
                        example: 0
                  bounced:
                    type: object
                    properties:
                      count:
                        type: integer
                        description: The count of bounced calls.
                        example: 0
            _currency:
              $ref: '#/components/schemas/currency'
    view-sms-statistics:
      type: object
      properties:
        http_code:
          type: integer
          description: The HTTP status code of the response.
          example: 200
        response_code:
          type: string
          description: The response code indicating the status of the operation.
          example: SUCCESS
        response_msg:
          type: string
          description: A message describing the outcome of the operation.
          example: Here are your data.
        data:
          type: object
          properties:
            total:
              type: object
              properties:
                outbound:
                  type: object
                  properties:
                    count:
                      type: integer
                      description: The total count of outbound SMS.
                      example: 1
                    price:
                      type: number
                      description: The total price of outbound SMS.
                      example: 5.81
                inbound:
                  type: object
                  properties:
                    count:
                      type: integer
                      description: The total count of inbound SMS.
                      example: 0
                bounced:
                  type: object
                  properties:
                    count:
                      type: integer
                      description: The total count of bounced SMS.
                      example: 0
            stat:
              type: array
              items:
                type: object
                properties:
                  date:
                    type: number
                    description: The date.
                    example: 1436918400
                  outbound:
                    type: object
                    properties:
                      count:
                        type: integer
                        description: The count of outbound SMS.
                        example: 83
                      price:
                        type: number
                        description: The price of outbound SMS.
                        example: 5.81
                  inbound:
                    type: object
                    properties:
                      count:
                        type: integer
                        description: The count of inbound SMS.
                        example: 0
                  bounced:
                    type: object
                    properties:
                      count:
                        type: integer
                        description: The count of bounced SMS.
                        example: 0
            _currency:
              $ref: '#/components/schemas/currency'
paths:
  /v3/statistics/voice:
    get:
      summary: View Voice Statistics
      operationId: view-voice-statistics
      description: >-
        _Get voice statistics_


        Refer to [Status Codes](/#status-codes) for definitions of HTTP status
        code responses.


        <div style="background-color: #FF6A4B; padding: 10px; border-radius:
        8px;">
          <span style="color: white;">This endpoint requires authentication,</span> 
          <a href="/#authentication" style="color: white; text-decoration: underline;">more info...</a>
        </div>
      security:
        - basicAuth: []
      parameters:
        - name: Content-Type
          in: header
          schema:
            type: string
          example: application/json
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/view-voice-statistics'
      x-codeSamples:
        - lang: curl
          source: |-
            curl --include \
                 --header "Authorization: Basic YXBpLXVzZXJuYW1lOmFwaS1wYXNzd29yZA=="  \

            'https://rest.clicksend.com/v3/statistics/voice'
        - lang: PHP
          source: >-
            <?php

            require_once(__DIR__ . '/vendor/autoload.php');


            // Configure HTTP basic authorization: BasicAuth

            $config = ClickSend\Configuration::getDefaultConfiguration()
                          ->setUsername('USERNAME')
                          ->setPassword('API_KEY');

            $apiInstance = new ClickSend\Api\StatisticsApi(new
            GuzzleHttp\Client(),$config);


            try {
                $result = $apiInstance->statisticsVoiceGet();
                print_r($result);
            } catch (Exception $e) {
                echo 'Exception when calling StatisticsApi->statisticsVoiceGet: ', $e->getMessage(), PHP_EOL;
            }

            ?>
        - lang: C#
          source: |-
            using IO.ClickSend.ClickSend.Api;
            using IO.ClickSend.Client;
            using IO.ClickSend.ClickSend.Model;

            var configuration = new Configuration()
            {
                Username = USERNAME, 
                Password = API_KEY  
            };
            var statisticsApi = new StatisticsApi(configuration);
            var response = statisticsApi.StatisticsVoiceGet();
        - lang: Java
          source: |-
            package ClickSend;

            import ClickSend.Api.StatisticsApi;

            public class view_voice_statistics {
              public static void main(String[] args) {
                ApiClient defaultClient = new ApiClient();
                defaultClient.setUsername("USERNAME");
                defaultClient.setPassword("API_KEY");
                StatisticsApi apiInstance = new StatisticsApi(defaultClient);
                try {
                    String result = apiInstance.statisticsVoiceGet();
                    System.out.println(result);
                } catch (ApiException e) {
                    System.err.println("Exception when calling StatisticsApi#statisticsVoiceGet");
                    e.printStackTrace();
                }
              }
            }
        - lang: Node.js
          source: |-
            var api = require('./api.js');

            var statisticsApi = new api.StatisticsApi("USERNAME", "API_KEY");

            statisticsApi.statisticsVoiceGet().then(function(response) {
              console.log(response.body);
            }).catch(function(err){
              console.error(err.body);
            });
        - lang: Ruby
          source: |-
            # load the gem
            require 'clicksend_client'
            require 'json'

            # setup authorization
            ClickSendClient.configure do |config|
              # Configure HTTP basic authorization: BasicAuth
              config.username = 'USERNAME'
              config.password = 'API_KEY'
            end

            api_instance = ClickSendClient::StatisticsApi.new

            begin
              # Get voice statistics
              result = api_instance.statistics_voice_get
              p JSON.parse(result)
            rescue ClickSendClient::ApiError => e
              puts "Exception when calling StatisticsApi->statistics_voice_get: #{e.response_body}"
            end
        - lang: Python
          source: >-
            from __future__ import print_function

            import clicksend_client


            # Configure HTTP basic authorization: BasicAuth

            configuration = clicksend_client.Configuration()

            configuration.username = 'USERNAME'

            configuration.password = 'API_KEY'


            # create an instance of the API class

            api_instance =
            clicksend_client.StatisticsApi(clicksend_client.ApiClient(configuration))


            try:
                # Get voice statistics
                api_response = api_instance.statistics_voice_get()
                print(api_response)
            except ApiException as e:
                print("Exception when calling StatisticsApi->statistics_voice_get: %s\n" % e)
        - lang: perl
          source: >-
            use WWW::ClickSendClient::StatisticsApi;


            my $username = 'YOUR_API_USER_NAME';

            my $password = 'YOUR_API_PASSWORD';


            my $api = WWW::ClickSendClient::StatisticsApi->new(username =>
            $username, password => $password);


            my $json_output = $api->statistics_voice_get();


            print $json_output;
        - lang: objc
          source: >-
            #import "CSStatisticsApi.h"


            CSDefaultConfiguration *apiConfig = [CSDefaultConfiguration
            sharedConfig];

            [apiConfig setUsername:@"USERNAME"];

            [apiConfig setPassword:@"PASSWORD"];


            CSStatisticsApi *statisticsApiInstance = [[CSStatisticsApi alloc]
            init];

            [statisticsApiInstance
            statisticsVoiceGetWithCompletionHandler:^(NSString *output, NSError
            *error) {
                if (error) {
                    NSLog(@"Error: %@", error);
                } else {
                    NSLog(@"%@", output);
                }
            }];
        - lang: swift
          source: >-
            import Alamofire


            if let authHeader = Request.authorizationHeader(user: "USERNAME",
            password: "PASSWORD") {
                ClickSendClientAPI.customHeaders = [authHeader.key : authHeader.value]
            }

            StatisticsAPI.statisticsVoiceGet { (dataString, error) in
                guard let dataString = dataString else {
                    print(error!)
                    return
                }
                if let data = dataString.data(using: String.Encoding.utf8) {
                    do {
                        if let dictonary = try (JSONSerialization.jsonObject(with: data, options: []) as? NSDictionary) {
                            print(dictonary)
                        } else {
                            print("Cannot convert the String value to JSON")
                        }
                    } catch let error as NSError {
                        print(error)
                    }
                }
            }
  /v3/statistics/sms:
    get:
      summary: View SMS Statistics
      operationId: view-sms-statistics
      description: >-
        _Get sms statistics_



        Refer to [Status Codes](/#status-codes) for definitions of HTTP status
        code responses.



        <div style="background-color: #FF6A4B; padding: 10px; border-radius:
        8px;">
          <span style="color: white;">This endpoint requires authentication,</span> 
          <a href="/#authentication" style="color: white; text-decoration: underline;">more info...</a>
        </div>
      security:
        - basicAuth: []
      parameters:
        - name: Content-Type
          in: header
          schema:
            type: string
          example: application/json
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/view-sms-statistics'
      x-codeSamples:
        - lang: curl
          source: |-
            curl --include \
                 --header "Authorization: Basic YXBpLXVzZXJuYW1lOmFwaS1wYXNzd29yZA=="  \

            'https://rest.clicksend.com/v3/statistics/sms'
        - lang: PHP
          source: >-
            <?php

            require_once(__DIR__ . '/vendor/autoload.php');


            // Configure HTTP basic authorization: BasicAuth

            $config = ClickSend\Configuration::getDefaultConfiguration()
                          ->setUsername('USERNAME')
                          ->setPassword('API_KEY');

            $apiInstance = new ClickSend\Api\StatisticsApi(new
            GuzzleHttp\Client(),$config);


            try {
                $result = $apiInstance->statisticsSmsGet();
                print_r($result);
            } catch (Exception $e) {
                echo 'Exception when calling StatisticsApi->statisticsSmsGet: ', $e->getMessage(), PHP_EOL;
            }

            ?>
        - lang: C#
          source: |-
            using IO.ClickSend.ClickSend.Api;
            using IO.ClickSend.Client;
            using IO.ClickSend.ClickSend.Model;

            var configuration = new Configuration()
            {
                Username = USERNAME, 
                Password = API_KEY  
            };
            var statisticsApi = new StatisticsApi(configuration);
            var response = statisticsApi.StatisticsSmsGet();
        - lang: Java
          source: |
            package ClickSend;

            import ClickSend.Api.StatisticsApi;

            public class view_sms_statistics {
               public static void main(String[] args) {
                  ApiClient defaultClient = new ApiClient();
                  defaultClient.setUsername("USERNAME");
                  defaultClient.setPassword("API_KEY");
                  StatisticsApi apiInstance = new StatisticsApi(defaultClient);
                  try {
                      String result = apiInstance.statisticsSmsGet();
                      System.out.println(result);
                  } catch (ApiException e) {
                      System.err.println("Exception when calling StatisticsApi#statisticsSmsGet");
                      e.printStackTrace();
                  }
               }
            }
        - lang: Node.js
          source: |-
            var api = require('./api.js');

            var statisticsApi = new api.StatisticsApi("USERNAME", "API_KEY");

            statisticsApi.statisticsSmsGet().then(function(response) {
              console.log(response.body);
            }).catch(function(err){
              console.error(err.body);
            });
        - lang: Ruby
          source: |-
            # load the gem
            require 'clicksend_client'
            require 'json'

            # setup authorization
            ClickSendClient.configure do |config|
              # Configure HTTP basic authorization: BasicAuth
              config.username = 'USERNAME'
              config.password = 'API_KEY'
            end

            api_instance = ClickSendClient::StatisticsApi.new

            begin
              # Get sms statistics
              result = api_instance.statistics_sms_get
              p result
            rescue ClickSendClient::ApiError => e
              puts "Exception when calling StatisticsApi->statistics_sms_get: #{e.response_body}"
            end
        - lang: Python
          source: >-
            from __future__ import print_function

            import clicksend_client

            from clicksend_client.rest import ApiException


            # Configure HTTP basic authorization: BasicAuth

            configuration = clicksend_client.Configuration()

            configuration.username = 'USERNAME'

            configuration.password = 'API_KEY'


            # create an instance of the API class

            api_instance =
            clicksend_client.StatisticsApi(clicksend_client.ApiClient(configuration))


            try:
                # Get sms statistics
                api_response = api_instance.statistics_sms_get()
                print(api_response)
            except ApiException as e:
                print("Exception when calling StatisticsApi->statistics_sms_get: %s\n" % e)
        - lang: perl
          source: >-
            use WWW::ClickSendClient::StatisticsApi;


            my $username = 'YOUR_API_USER_NAME';

            my $password = 'YOUR_API_PASSWORD';


            my $api = WWW::ClickSendClient::StatisticsApi->new(username =>
            $username, password => $password);


            my $json_output = $api->statistics_sms_get();


            print $json_output;
        - lang: objc
          source: >-
            #import "CSStatisticsApi.h"

            #import "CSDefaultConfiguration.h"


            CSDefaultConfiguration *apiConfig = [CSDefaultConfiguration
            sharedConfig];

            [apiConfig setUsername:@"USERNAME"];

            [apiConfig setPassword:@"PASSWORD"];


            CSStatisticsApi *statisticsApiInstance = [[CSStatisticsApi alloc]
            init];

            [statisticsApiInstance
            statisticsSmsGetWithCompletionHandler:^(NSString *output, NSError
            *error) {
                if (error) {
                    NSLog(@"Error: %@", error);
                } else {
                    NSLog(@"%@", output);
                }
            }];
        - lang: swift
          source: >-
            import Alamofire


            if let authHeader = Request.authorizationHeader(user: "USERNAME",
            password: "PASSWORD") {
                ClickSendClientAPI.customHeaders = [authHeader.key : authHeader.value]
            }

            StatisticsAPI.statisticsSmsGet { (dataString, error) in
                guard let dataString = dataString else {
                    print(error!)
                    return
                }
                if let data = dataString.data(using: String.Encoding.utf8) {
                    do {
                        if let dictonary = try (JSONSerialization.jsonObject(with: data, options: []) as? NSDictionary) {
                            print(dictonary)
                        } else {
                            print("Cannot convert the String value to JSON")
                        }
                    } catch let error as NSError {
                        print(error)
                    }
                }
            }
