Realtime Usage

Overview

The Realtime Usage API returns realtime data for each Media API that your Dolby.io app uses for a specific date range. You can retrieve up to one year of data per API call. The returned data includes the following:

FieldDescription
PathThe Media API endpoint.
JobsThe number of jobs completed.
SucceededThe number of successful jobs.
FailedThe number of failed jobs.

Pagination

The realtime usage data returned might exceed the maximum results per page. When this occurs, the response includes a next_token parameter and value. This next_token parameter and value can be used in additional requests to return more results until all results are returned.

import os
import requests

# Add your API token as an environmental variable or hard coded value.
api_token = os.getenv("DOLBYIO_API_TOKEN", "your_token_here")

# Add the 'next_token' returned from a previous request as an environmental variable or hard coded value.
next_token = os.getenv("DOLBYIO_NEXT_TOKEN", "your_token_here")

url = "https://api.dolby.com/media/usage"
headers = {
    "Authorization": "Bearer {0}".format(api_token),
    "Accept": "application/json"
}

# Use YYYY-MM-DD for the date format.
payload = {'from': '2022-01-01', 'to': '2022-12-31', 'next_token': next_token}


response = requests.get(url, headers=headers, params=payload)
response.raise_for_status()
data = response.json()
const axios = require("axios").default

// Add your API token as an environmental variable or hard coded value.  
const api_token = process.env.DOLBYIO_API_TOKEN || "your_token_here"  

// Add the 'next_token' returned from a previous request as an environmental variable or hard coded value.
const next_token = process.env.DOLBYIO_NEXT_TOKEN || "your_token_here"  


// Use YYYY-MM-DD for the date format.
const config = {
  method: "get",
  url: "https://api.dolby.com/media/usage",
  headers: {
    "Authorization": `Bearer ${api_token}`,
    "Accept": "application/json"
  },
  params: {
    from: '2022-01-01',
    to: '2022-01-31',
    next_token: next_token
  }
}

axios(config)
  .then(function(response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function(error) {
    console.log(error)
  })
#!/bin/bash

# Add your API token as an environmental variable or hard coded value.
API_TOKEN=${DOLBYIO_API_TOKEN:-"your_token_here"}

# Add the 'next_token' returned from a previous request as an environmental variable or hard coded value.
NEXT_TOKEN=${DOLBYIO_NEXT_TOKEN:-"your_token_here"}


# Use YYYY-MM-DD for the date format.
curl --request GET \
     --url https://api.dolby.com/media/usage?from=2022-01-01&to=2022-01-31&next_token=$NEXT_TOKEN \
     --header 'Accept: application/json'

Code example

This code example shows you how to retrieve one month of usage data for your Dolby.io app. To specify what Dolby.io app you want to retrieve usage data for, use an API Token associated with that app when making a Realtime Usage API call.

import os
import requests

# Add your API token as an environmental variable or hard coded value.
api_token = os.getenv("DOLBYIO_API_TOKEN", "your_token_here")

url = "https://api.dolby.com/media/usage"
headers = {
    "Authorization": "Bearer {0}".format(api_token),
    "Accept": "application/json"
}

# Use YYYY-MM-DD for the date format.
payload = {'from': '2022-01-01', 'to': '2022-01-31'}


response = requests.get(url, headers=headers, params=payload)
response.raise_for_status()
data = response.json()
const axios = require("axios").default

// Add your API token as an environmental variable or hard coded value.  
const api_token = process.env.DOLBYIO_API_TOKEN || "your_token_here"  

// Use YYYY-MM-DD for the date format.
const config = {
  method: "get",
  url: "https://api.dolby.com/media/usage",
  headers: {
    "Authorization": `Bearer ${api_token}`,
    "Accept": "application/json"
  },
  params: {
    from: '2022-01-01',
    to: '2022-01-31'
  }
}

axios(config)
  .then(function(response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function(error) {
    console.log(error)
  })
#!/bin/bash

# Add your API token as an environmental variable or hard coded value.
API_TOKEN=${DOLBYIO_API_TOKEN:-"your_token_here"}

# Use YYYY-MM-DD for the date format.
curl --request GET \
     --url https://api.dolby.com/media/usage?from=2022-01-01&to=2022-01-31 \
     --header 'Accept: application/json'

Did this page help you?