Dart Requires Chilkat v11.7.0+
Dart
Stripe: Export a period of account activity
See more Stripe Examples
Export account activity for a UTC date range to CSV, including transaction references, fees, net amounts, and currencies.
Stripe documentation and cURL example
Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
var success = false;
// Requires an unlocked Chilkat bundle. See Global Unlock Sample.
// Supply a restricted sandbox key from merchant-controlled configuration.
final apiKey = 'YOUR_STRIPE_TEST_KEY';
final curl = CkHttpCurl();
final cmd = CkStringBuilder();
final json = CkJsonObject();
var replaced = 0;
// Example UTC interval: 1 October 2026 inclusive through 1 November exclusive.
final fromTime = '1790812800';
final untilTime = '1793491200';
final ledger = CkCsv();
ledger.hasColumnNames = true;
var outputRow = 0;
ledger.setColumnName(0, 'id');
ledger.setColumnName(1, 'created');
ledger.setColumnName(2, 'source');
ledger.setColumnName(3, 'reporting_category');
ledger.setColumnName(4, 'amount');
ledger.setColumnName(5, 'fee');
ledger.setColumnName(6, 'net');
ledger.setColumnName(7, 'currency');
final pageSuffix = CkStringBuilder();
var more = true;
var cursor = '';
while (more) {
// curl -X GET "https://api.stripe.com/v1/balance_transactions?created%5Bgte%5D={fromTime}&created%5Blt%5D={untilTime}&limit=100" \
// -u "$STRIPE_API_KEY:" \
// -H "Stripe-Version: 2026-10-28.endive"
cmd.setString('curl -X GET "https://api.stripe.com/v1/balance_transactions?created%5Bgte%5D=@FROM@&created%5Blt%5D=@UNTIL@&limit=100@CURSOR@"');
cmd.append(' -u "@KEY@:"');
cmd.append(' -H "Stripe-Version: 2026-10-28.endive"');
replaced = cmd.replace('@CURSOR@', pageSuffix.getAsString());
replaced = cmd.replace('@FROM@', fromTime);
replaced = cmd.replace('@UNTIL@', untilTime);
replaced = cmd.replace('@KEY@', apiKey);
success = true;
try {
curl.doYourThing(cmd.getAsString());
} on ChilkatException {
success = false;
}
if (!success) {
print('No HTTP response. Chilkat failure code: ${curl.failReason}');
return;
}
success = true;
try {
curl.getResponseJson(json);
} on ChilkatException {
success = false;
}
if ((curl.statusCode != 200) || (!success)) {
print('Stripe HTTP ${curl.statusCode} Request-Id: ${curl.getResponseHeaderField('Request-Id')}');
if (success) {
print(json.stringOf('error.message'));
}
return;
}
var i = 0;
final count = json.sizeOfArray('data');
while (i < count) {
json.i = i;
ledger.setCell(outputRow, 0, json.stringOf('data[i].id'));
ledger.setCell(outputRow, 1, json.stringOf('data[i].created'));
ledger.setCell(outputRow, 2, json.stringOf('data[i].source'));
ledger.setCell(outputRow, 3, json.stringOf('data[i].reporting_category'));
ledger.setCell(outputRow, 4, json.stringOf('data[i].amount'));
ledger.setCell(outputRow, 5, json.stringOf('data[i].fee'));
ledger.setCell(outputRow, 6, json.stringOf('data[i].net'));
ledger.setCell(outputRow, 7, json.stringOf('data[i].currency'));
outputRow++;
i++;
}
more = json.boolOf('has_more');
if (more) {
final next = json.stringOf('data[i].id');
if ((count < 1) || ((next == '') || (next == cursor))) {
print('Invalid pagination cursor.');
return;
}
cursor = next;
pageSuffix.setString('&starting_after=');
pageSuffix.append(cursor);
}
}
success = true;
try {
ledger.saveFile('stripe-balance-transactions.csv');
} on ChilkatException {
success = false;
}
if (!success) {
print(ledger.lastErrorText);
return;
}
print('Exported rows: $outputRow');
}