Node.js Requires Chilkat v11.7.0+
Node.js
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 Node.js Downloads
NODEJS_PRELUDE
function chilkatExample() {
var success = false;
// Requires an unlocked Chilkat bundle. See Global Unlock Sample.
// Supply a restricted sandbox key from merchant-controlled configuration.
var apiKey = "YOUR_STRIPE_TEST_KEY";
var curl = new chilkat.HttpCurl();
var cmd = new chilkat.StringBuilder();
var json = new chilkat.JsonObject();
var replaced;
// curl -X GET "https://api.stripe.com/v1/balance" \
// -u "$STRIPE_API_KEY:" \
// -H "Stripe-Version: 2026-10-28.endive"
cmd.SetString("curl -X GET \"https://api.stripe.com/v1/balance\"");
cmd.Append(" -u \"@KEY@:\"");
cmd.Append(" -H \"Stripe-Version: 2026-10-28.endive\"");
replaced = cmd.Replace("@KEY@",apiKey);
success = curl.DoYourThing(cmd.GetAsString());
if (success !== true) {
console.log("No HTTP response. Chilkat failure code: " + curl.FailReason);
return;
}
success = curl.GetResponseJson(json);
if ((curl.StatusCode !== 200) || (success !== true)) {
console.log("Stripe HTTP " + curl.StatusCode + " Request-Id: " + curl.GetResponseHeaderField("Request-Id"));
if (success == true) {
console.log(json.StringOf("error.message"));
}
return;
}
// Amounts are integer minor units. Read them as text to preserve large balances.
var availableIndex = 0;
while ((availableIndex < json.SizeOfArray("available"))) {
json.I = availableIndex;
console.log("available: " + json.StringOf("available[i].amount") + " " + json.StringOf("available[i].currency"));
availableIndex = availableIndex+1;
}
var pendingIndex = 0;
while ((pendingIndex < json.SizeOfArray("pending"))) {
json.I = pendingIndex;
console.log("pending: " + json.StringOf("pending[i].amount") + " " + json.StringOf("pending[i].currency"));
pendingIndex = pendingIndex+1;
}
}
chilkatExample();