Rust Requires Chilkat v11.7.0+
Rust
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 Rust Downloads
let mut success = false;
// Requires an unlocked Chilkat bundle. See Global Unlock Sample.
// Supply a restricted sandbox key from merchant-controlled configuration.
let api_key = "YOUR_STRIPE_TEST_KEY".to_string();
let curl = chilkat::HttpCurl::new();
let cmd = chilkat::StringBuilder::new();
let json = chilkat::JsonObject::new();
// Example UTC interval: 1 October 2026 inclusive through 1 November exclusive.
let from_time = "1790812800".to_string();
let until_time = "1793491200".to_string();
let ledger = chilkat::Csv::new();
ledger.set_has_column_names(true);
let mut output_row = 0;
let _ = ledger.set_column_name(0, "id");
let _ = ledger.set_column_name(1, "created");
let _ = ledger.set_column_name(2, "source");
let _ = ledger.set_column_name(3, "reporting_category");
let _ = ledger.set_column_name(4, "amount");
let _ = ledger.set_column_name(5, "fee");
let _ = ledger.set_column_name(6, "net");
let _ = ledger.set_column_name(7, "currency");
let page_suffix = chilkat::StringBuilder::new();
let mut more = true;
let mut cursor = String::new();
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"
let _ = cmd.set_string("curl -X GET \"https://api.stripe.com/v1/balance_transactions?created%5Bgte%5D=@FROM@&created%5Blt%5D=@UNTIL@&limit=100@CURSOR@\"");
let _ = cmd.append(" -u \"@KEY@:\"");
let _ = cmd.append(" -H \"Stripe-Version: 2026-10-28.endive\"");
let _ = cmd.replace("@CURSOR@", &page_suffix.get_as_string().unwrap_or_default());
let _ = cmd.replace("@FROM@", &from_time);
let _ = cmd.replace("@UNTIL@", &until_time);
let _ = cmd.replace("@KEY@", &api_key);
success = curl.do_your_thing(&cmd.get_as_string().unwrap_or_default()).is_ok();
if !success {
println!("No HTTP response. Chilkat failure code: {}", curl.fail_reason());
return;
}
success = curl.get_response_json(&json).is_ok();
if (curl.status_code() != 200) || (!success) {
println!("Stripe HTTP {} Request-Id: {}", curl.status_code(), curl.get_response_header_field("Request-Id").unwrap_or_default());
if success {
println!("{}", json.string_of("error.message").unwrap_or_default());
}
return;
}
let mut i = 0;
let count = json.size_of_array("data");
while i < count {
json.set_i(i);
let _ = ledger.set_cell(output_row, 0, &json.string_of("data[i].id").unwrap_or_default());
let _ = ledger.set_cell(output_row, 1, &json.string_of("data[i].created").unwrap_or_default());
let _ = ledger.set_cell(output_row, 2, &json.string_of("data[i].source").unwrap_or_default());
let _ = ledger.set_cell(output_row, 3, &json.string_of("data[i].reporting_category").unwrap_or_default());
let _ = ledger.set_cell(output_row, 4, &json.string_of("data[i].amount").unwrap_or_default());
let _ = ledger.set_cell(output_row, 5, &json.string_of("data[i].fee").unwrap_or_default());
let _ = ledger.set_cell(output_row, 6, &json.string_of("data[i].net").unwrap_or_default());
let _ = ledger.set_cell(output_row, 7, &json.string_of("data[i].currency").unwrap_or_default());
output_row = output_row + 1;
i = i + 1;
}
more = json.bool_of("has_more");
if more {
let next = json.string_of("data[i].id").unwrap_or_default();
if (count < 1) || ((next == "") || (next == cursor)) {
println!("Invalid pagination cursor.");
return;
}
cursor = next.clone();
let _ = page_suffix.set_string("&starting_after=");
let _ = page_suffix.append(&cursor);
}
}
if ledger.save_file("stripe-balance-transactions.csv").is_err() {
println!("{}", ledger.last_error_text());
return;
}
println!("Exported rows: {}", output_row);