Reports (CSV exports)
A report is a CSV export made from our ledger: your balance transactions, pay-ins or payouts for one currency and a range of your own days. It is made in the background; you ask for it, wait for report.ready, and download it.
Ask for a report
POST /v1/reportsReference
- Scope:
reports:write - Success: HTTP 202
Request
| Field | Notes |
|---|---|
kind | balance_transactions, payins or payouts |
currency | INR (the default) or USDT |
from, to | YYYY-MM-DD, both inclusive. Days are your merchant time zone's days (shown as time_zone on the report); at most 92 of them |
Response
202 with the report in status queued. It becomes ready — or failed, with error — and you get the event report.ready.
Errors
400 invalid_request when from is after to or the range is longer than 92 days.
Download it
GET /v1/reports/{id}Reference
- Scope:
reports:write - Success: HTTP 200
Once the report is ready, it carries download_url, a short-lived link (see download_expires_at). Download the file at once and do not store the link — fetch the report again for a fresh one. row_count and sha256 let you check what you got. The file is UTF-8 with a byte-order mark, so it opens cleanly in spreadsheet programs.
Example
samples/ts/report.ts samples/php/report.php// Reports: a CSV of your balance transactions (or pay-ins, payouts) for your own days.
// bun report.ts 2026-11-01 2026-11-30
import { nicepay } from "./nicepay.ts";
interface Report {
readonly id: string;
readonly status: string;
readonly time_zone: string;
readonly download_url: string | null;
readonly row_count: number | null;
readonly sha256: string | null;
readonly error: string | null;
}
const today = new Date().toISOString().slice(0, 10);
const from = process.argv[2] ?? today;
const to = process.argv[3] ?? today;
// Days are your merchant time zone's days, inclusive; at most 92 of them.
let report = await nicepay<Report>("POST", "/v1/reports", { body: { kind: "balance_transactions", currency: "INR", from, to } });
console.log(`report ${report.id} ${report.status} (${report.time_zone})`);
// It is made in the background (you also get a report.ready event). Poll gently.
for (let i = 0; i < 60 && report.status === "queued"; i += 1) {
await new Promise((resolve) => setTimeout(resolve, 1000));
report = await nicepay<Report>("GET", `/v1/reports/${report.id}`);
}
if (report.status !== "ready" || !report.download_url) throw new Error(`report ${report.status}: ${String(report.error)}`);
// The link is short-lived: fetch it now, don't store it. UTF-8 with a byte-order mark.
let csv = await (await fetch(report.download_url)).text();
if (csv.charCodeAt(0) === 0xfeff) csv = csv.slice(1); // the byte-order mark
const [header, ...rows] = csv.trim().split("\n");
console.log(`ready: ${String(report.row_count)} rows, sha256 ${String(report.sha256).slice(0, 12)}…`);
console.log(`columns: ${String(header)}`);
console.log(`data lines: ${String(rows.length)}`);<?php
// A CSV of your pay-ins for your own days (your merchant time zone), e.g. for accounting.
// php report.php 2026-11-01 2026-11-30
declare(strict_types=1);
require __DIR__ . '/nicepay.php';
$from = $argv[1] ?? gmdate('Y-m-d');
$to = $argv[2] ?? $from;
$report = nicepay('POST', '/v1/reports', ['body' => ['kind' => 'payins', 'currency' => 'INR', 'from' => $from, 'to' => $to]]);
for ($i = 0; $i < 60 && $report['status'] === 'queued'; $i++) {
sleep(1);
$report = nicepay('GET', "/v1/reports/{$report['id']}");
}
if ($report['status'] !== 'ready') {
throw new RuntimeException("report {$report['status']}: {$report['error']}");
}
// The link is short-lived: download now. UTF-8 with a byte-order mark (opens cleanly in Excel).
$csv = file_get_contents($report['download_url']);
if ($csv === false) {
throw new RuntimeException('the download failed; ask for the report again to get a fresh link');
}
$csv = preg_replace('/^\xEF\xBB\xBF/', '', $csv);
$lines = array_values(array_filter(explode("\n", trim((string) $csv)), 'strlen'));
$rows = array_map('str_getcsv', $lines);
echo "ready: {$report['row_count']} rows; columns: " . implode(',', $rows[0] ?? []) . "\n";
echo 'data lines: ' . (count($rows) - 1) . "\n";Reconcile daily
Once a day, export yesterday's balance transactions (or page through GET/v1/balance-transactions) and match each entry to your own records by its source (type and id). Every credit, fee, payout reserve, release and reversal is an entry; they add up to your balance exactly.