Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time

REST API: GET account consumption

This method can be used if you want to retrieve the account-wide consumption statistics. These consist of counters of various services, such as the number of emails or api calls sent. By sending a GET request to the following URL, you can fetch the account-wide consumption statistics: https://api.copernica.com/v3/consumption?access_token=xxxx

Parameters

The following parameters are required:

  • begin: The timestamp indicating the start of the period for which statistics should be retrieved (YYYY-MM-DD format).
  • end: The timestamp indicating the end of the period for which statistics should be retrieved (YYYY-MM-DD format).

Response data

This method returns a JSON object containing the following fields:

  • emails: the number of emails sent
  • texts: the number of text messages sent
  • fax: the number of fax messages sent
  • webpages: the number of webpages
  • apicalls: the number of api calls
  • litmustests: the number of Litmus tests
  • twofiftyoktests: the number of twoFiftyOk tests

PHP example

The following PHP script calls this API method:

// dependencies
require_once('copernica_rest_api.php');
// change this into your access token
$api = new CopernicaRestAPI("your-access-token", 3);
// set the required parameters
$parameters = array(
    'begin'  => "2020-06-01",
    'end'    => "2020-07-01"
);
// do the call, and print result
print_r($api->get("consumption", $parameters));

The example above requires the CopernicaRestApi class.

More information