Diska
API guides

Export the call history

The whole history to CSV, or with transcripts to JSONL, using cursor pagination.

This guide exports the organization's calls with GET /v1/calls. It uses cursor pagination, which costs the same on any page, even with hundreds of thousands of calls.

Before you start

  • An API key with the Chamadas e transcrições (calls:read) scope.
  • Python 3.11 or later with requests, or Node.js 18 or later.

Export to CSV

import csv
import os
import time

import requests

API = "https://api.diska.ai/v1"
FIELDS = [
    "id", "started_at", "ended_at", "duration_seconds", "channel", "direction", "status",
    "agent_name", "caller_name", "caller_contact", "end_reason", "summary",
]
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['DISKA_API_KEY']}"


def get(path: str, params: dict | None = None) -> dict:
    while True:
        response = session.get(f"{API}{path}", params=params, timeout=60)
        if response.status_code == 429:  # rate limit: wait as long as the API says
            time.sleep(int(response.headers.get("Retry-After", "5")))
            continue
        response.raise_for_status()
        return response.json()


params = {"cursor": "start", "limit": 200}  # optional filters: agent_id, status, channel
total = 0
with open("calls.csv", "w", newline="", encoding="utf-8") as file:
    writer = csv.DictWriter(file, fieldnames=FIELDS, extrasaction="ignore")
    writer.writeheader()
    while True:
        page = get("/calls", params)
        writer.writerows(page["items"])
        total += len(page["items"])
        if not page["next_cursor"]:
            break
        params["cursor"] = page["next_cursor"]
print(f"{total} calls exported to calls.csv")
  • The first page asks for cursor=start; the next ones use the next_cursor received. When next_cursor is null, you are done.
  • limit=200 is the maximum per page.
  • If the API answers 429, the script waits as long as the Retry-After header says and repeats the request.
  • To export only part of it, add filters to params: agent_id, status or channel. See the parameters.

Include transcripts

The list does not carry the transcript. To get it, ask for each call's detail and save one JSON line per call:

import json
import os
import time

import requests

API = "https://api.diska.ai/v1"
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['DISKA_API_KEY']}"


def get(path: str, params: dict | None = None) -> dict:
    while True:
        response = session.get(f"{API}{path}", params=params, timeout=60)
        if response.status_code == 429:
            time.sleep(int(response.headers.get("Retry-After", "5")))
            continue
        response.raise_for_status()
        return response.json()


params = {"cursor": "start", "limit": 200, "status": "completed"}
with open("calls.jsonl", "w", encoding="utf-8") as file:
    while True:
        page = get("/calls", params)
        for call in page["items"]:
            detail = get(f"/calls/{call['id']}")  # transcript, actions and post-call result
            file.write(json.dumps(detail, ensure_ascii=False) + "\n")
            time.sleep(0.5)  # at most 120 requests per minute per key
        if not page["next_cursor"]:
            break
        params["cursor"] = page["next_cursor"]

Each line has the same content as GET /v1/calls/{call_id}: transcript (messages), executed actions and post-call result. The script makes one request per call and waits half a second between them to stay under 120 requests per minute: 10,000 calls take about an hour and a half.

Export only what is new

The API does not filter by date, but the list is newest first. To export only since the last run, stop when started_at is older than that date, like the calls_since function in Sync calls with your CRM.

Take care

  • Exports contain personal data: contacts, names and what was said. Store them with the same care as the rest of your customers' data.
  • Recording audio is not exported by the API. Listen to recordings in History.
Copyright © 2026