Sample code for 30+ languages & platforms
Rust Requires Chilkat v11.7.0+

Stripe: Show available and pending balances by currency

See more Stripe Examples

Read the available and pending account balances for every currency returned by Stripe.

Stripe documentation and cURL example

Chilkat Rust Downloads

Rust
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();

// curl -X GET "https://api.stripe.com/v1/balance" \
//   -u "$STRIPE_API_KEY:" \
//   -H "Stripe-Version: 2026-10-28.endive"
let _ = cmd.set_string("curl -X GET \"https://api.stripe.com/v1/balance\"");
let _ = cmd.append(" -u \"@KEY@:\"");
let _ = cmd.append(" -H \"Stripe-Version: 2026-10-28.endive\"");
let replaced = 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;
}

// Amounts are integer minor units. Read them as text to preserve large balances.

let mut available_index = 0;
while available_index < json.size_of_array("available") {
    json.set_i(available_index);
    println!("available: {} {}", json.string_of("available[i].amount").unwrap_or_default(), json.string_of("available[i].currency").unwrap_or_default());
    available_index = available_index + 1;
}

let mut pending_index = 0;
while pending_index < json.size_of_array("pending") {
    json.set_i(pending_index);
    println!("pending: {} {}", json.string_of("pending[i].amount").unwrap_or_default(), json.string_of("pending[i].currency").unwrap_or_default());
    pending_index = pending_index + 1;
}