SuperAPI AI 工具集

telnyx-account-reports-javascript

数据与分析

查看项目

更新于 10-16 07:20

技能介绍

用途:围绕 Telnyx 账户用量数据的生成与检索,提供 JavaScript SDK 示例,用于计费、分析与对账。安装:npm install telnyx;初始化:import Telnyx from 'telnyx'; const client = new Telnyx({ apiKey: process.env['TELNYX_API_KEY'] });

主要能力:1) 通话事件列表 GET /call_events,按过滤器查询并按 occurred_at 排序;未提供 leg_id 或 application_session_id 过滤时仅返回最近 24 小时事件。2) 创建与获取账本计费组报表 POST/GET /ledger_billing_group_reports,可选 month、year,返回状态含 pending、complete、failed、deleted 及 report_url。3) MDR 明细报表:列出、创建、获取、删除 /legacy/reporting/batch_detail_records/messaging,创建必填 start_time、end_time,可选 connections、directions、filters、include_message_body、managed_accounts、profiles、record_types、report_name、select_all_managed_accounts、timezone。4) CDR 报表:/legacy/reporting/batch_detail_records/voice 的列出、创建、获取、删除,并可 GET .../voice/fields 获取可用字段(Billing、Interaction Data、Number Information、Telephony Data)。5) 用量报表:MDR(/legacy/reporting/usage_reports/messaging)、CDR(/legacy/reporting/usage_reports/voice)及号码查询(number_lookup)的列出、创建、按 ID 获取与删除。

使用方式:列表方法返回自动分页迭代器,可用 for await (const item of result) 自动翻页;各创建接口使用 client.legacy.reporting...create({...}),检索与删除传入报表 UUID。

错误处理:可能遇到网络错误、429 限流、422 校验错误、401 认证错误;示例按 APIConnectionError、RateLimitError、APIError 分别处理,429 可读取 retry-after 后重试。

限制:部分接口状态、字段类型与可选参数以资料所列为准;报表生成具有异步状态,需要轮询或从 report_url 获取结果;其余未在资料中说明的行为暂未提供。