Obtaining cloud analytics data from CDS
This guide will help you get cloud analytics data from CDS using the API. We will use a common API approach as an example in this guide. The API calls will be triggered to fetch the necessary data whenever needed. Additionally, we will cover how to authenticate your requests and process the returned data effectively for your application's requirements.
Prerequisites
- Node.js installed on your server.
Step-by-Step Guide
Step 1: Setting Up the Server
-
Install Node.js and npm if not already installed. Follow the installation instructions from the official Node.js website: Node.js.
-
Create a new project directory and navigate to it in your terminal:
mkdir wildix-cds-ca
cd wildix-cds-ca -
Initialize a new Node.js project:
npm init -y -
Change type to module: add type to package.json
"type": "module" -
Prepare authorization token: Open in new tab
Step 2.1: Creating a Script for CallHistory
2.1.1 Install necessary dependencies:
npm i @wildix/wda-history-client
Create a file named callHistory.js in your project directory and add the following code:
import { WdaHistoryClient, QueryConversationsCommand } from '@wildix/wda-history-client';
const API_KEY = 'wsk-******';
// Specify params for your request
const DATE_FROM = '2025-01-01';
const DATE_TO = '2025-08-01';
const client = new WdaHistoryClient({
token: {
token: () => Promise.resolve(API_KEY),
}});
async function run () {
const params = {
offset: 0,
limit: 100,
filter: {
from: new Date(DATE_FROM),
to: new Date(DATE_TO)
}
}
return await client.send(new QueryConversationsCommand(params))
}
run()
.then(items => console.log(items))
.catch(e => console.error(e));
Step 2.2: Creating a Script for a get dump file
2.2.1 Install necessary dependencies:
npm i @wildix/cds-ca-client
Create a file named getDump.js in your project directory and add the following code:
import { CdsCAClient, CreateDumpCommand, GetDumpCommand } from '@wildix/cds-ca-client';
const API_KEY = 'wsk-******';
// Specify params for your request
const DATE_FROM = '2025-01-01';
const DATE_TO = '2025-08-01';
const TYPE = 'calls';
const client = new CdsCAClient({
token: {
token: () => Promise.resolve(API_KEY),
}});
const sleep = async (sec) => await new Promise((resolve) => setTimeout(resolve, sec * 1000));
async function run () {
const params = {
type: TYPE,
dateFrom: DATE_FROM,
dateTo: DATE_TO,
}
const { id } = await client.send(new CreateDumpCommand(params))
while (true) {
const { presignedDownloadUrl, status } = await client.send(new GetDumpCommand({id}));
console.log(status)
if (presignedDownloadUrl) {
return presignedDownloadUrl;
}
await sleep(10);
}
}
run()
.then(items => console.log(items))
.catch(e => console.error(e));
Step 3: Running the scripts
Start your Node.js server by running:
node callHistory.js
node getDump.js
Conclusion
This guide provided a step-by-step approach to get Cloud Analytics data from CDS. Customize the script as per your requirements to make the most out of this API.