Stripe API Documentation Sample : Balance Object_GET Operation - snehilkusum/API-Documentation-Samples GitHub Wiki
The Stripe API is a powerful interface that allows developers to integrate payment processing capabilities into web and mobile applications. It enables online finance management for e-commerce platforms and digital businesses.
Stripe provides a robust API that allows developers to:
- Manage online payments
- Handle credit card transactions
- Monitor balances and refunds
- Automate payment workflows
In this document, we focus specifically on the Balance API, which helps retrieve account funds data including available, pending, and reserved amounts.
All Stripe API requests use the following base URL to connect::
https://api.stripe.com
โ Note: You must register for a developer account at https://stripe.com/ to obtain your API keys and enable access to the endpoints.
The Stripe API uses API keys to authenticate requests. You can view and manage your API keys in the Stripe Dashboard.
Test mode secret keys have the prefix sk_test_
and live mode secret keys have the prefix sk_live_
. Alternatively, you can use restricted API keys for granular permissions.
Your API keys carry many privileges, so be sure to keep them secure! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so forth.
Authentication to the API is performed via HTTP Basic Auth. Provide your API key as the basic auth username value. You do not need to provide a password.
If you need to authenticate via bearer auth (e.g., for a cross-origin request), use -H "Authorization: Bearer ,[object Object],"
instead of -u ,[object Object]
.
Connect the CLI to your Stripe account by logging in to persist your secret key locally. See also Log in to the CLI.
All API requests must be made over HTTPS. Calls made over plain HTTP will fail. API requests without authentication will also fail.
curl https://api.stripe.com/v1/charges \
-u sk_test_51RnldHROvpfI1pPNe8vgG9uHYYkkg80SR0KsVKHLyCqQoQfOXcH8ITSagoVlzFWCySOlUHwAzdVYmjz6aeki0gGt00plSgrjHw:
# The colon prevents curl from asking for a password.
const Stripe = require('stripe');
const stripe = Stripe('sk_test_51RnldHROvpfI1pPNe8vgG9uHYYkkg80SR0KsVKHLyCqQoQfOXcH8ITSagoVlzFWCySOlUHwAzdVYmjz6aeki0gGt00plSgrjHw');
var charge = await stripe.charges.retrieve(
'ch_3LiiC52eZvKYlo2C1da66ZSQ',
{
apiKey: 'sk_test_51RnldHROvpfI1pPNe8vgG9uHYYkkg80SR0KsVKHLyCqQoQfOXcH8ITSagoVlzFWCySOlUHwAzdVYmjz6aeki0gGt00plSgrjHw'
}
);
Before you can make requests to the Stripe API, you need to generate a secret API key.
- Go to https://dashboard.stripe.com/login and log in to your developer account.
- Navigate to Developers โ API keys in the left-hand sidebar.
- Under Standard keys, you will find:
- Publishable key (used on frontend)
- Secret key (used on backend or server-side requests)
- Click Reveal live key token or use the test key to start development.
> ๐ก๏ธ Keep your secret key confidential. Do not expose it in frontend code or version control.
When you call the GET /v1/balance
endpoint, the Stripe API returns a balance
object. This object represents the current balance of your Stripe account, including available funds, pending transactions, and reserved amounts for refunds or disputes.
Use this endpoint to check the available, pending, and reserved balances of your Stripe account.
`GET `{{baseUrl}}/v1/balance
`200` OK
`GET` https://api.stripe.com/v1/balance
{
"object": "balance",
"available": [
{
"amount": 666670,
"currency": "usd",
"source_types": {
"card": 666670
}
}
],
"connect_reserved": [
{
"amount": 0,
"currency": "usd"
}
],
"livemode": false,
"pending": [
{
"amount": 61414,
"currency": "usd",
"source_types": {
"card": 61414
}
}
]
}
Attribute | Type | Description |
---|---|---|
object | string | Always "balance" โ identifies the type of the object returned. |
available | array | List of balances available to transfer or pay out immediately. Each object in the array represents a currency. |
available[].amount | integer | Amount available in the smallest currency unit (e.g., cents for USD/CAD). |
available[].currency | string | ISO currency code (e.g., cad, usd). |
available[].source_types.card | integer | Amount available from card payments. |
livemode | boolean | true if the balance is from the live environment, false if it's from the test environment. |
pending | array | List of funds that are not yet available but will become available soon (e.g., in transit). |
pending[].amount | integer | Amount pending settlement, in the smallest currency unit. |
pending[].currency | string | ISO currency code of the pending balance. |
pending[].source_types.card | integer | Pending amount from card sources. |
refund_and_dispute_prefunding | object | Holds amounts Stripe reserves to prefund refunds and dispute payouts. |
refund_and_dispute_prefunding.available[].amount | integer | Amount currently reserved and available for refunds or disputes. |
refund_and_dispute_prefunding.available[].currency | string | Currency of reserved funds. |
refund_and_dispute_prefunding.pending[].amount | integer | Pending reserved amount not yet available. |
refund_and_dispute_prefunding.pending[].currency | string | Currency of pending reserved funds. |
This object is particularly useful when: - You want to display available balance for payouts. - You need to monitor pending amounts before initiating transfers. - You want to check if you have enough funds for refunds or disputes. - You are operating in multi-currency environments (e.g., USD, CAD, EUR) and need a breakdown by currency and source type.
Header | Value |
---|---|
Server | nginx |
Date | Tue, 22 Jul 2025 22:56:34 GMT |
Content-Type | application/json |
Content-Length | 517 |
Connection | keep-alive |
Access-Control-Allow-Credentials | true |
Access-Control-Allow-Methods | GET, HEAD, PUT, PATCH, POST, DELETE |
Access-Control-Allow-Origin | * |
Access-Control-Expose-Headers | Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required |
Access-Control-Max-Age | 300 |
Cache-Control | no-cache, no-store |
Content-Security-Policy | base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none'; img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=qvKPBrLu4aLo_kji8qH8lYIF1thNPRUUmmctgZ-f7F2FF1FCCxd2w9pb6G_Nmjl0uM7qvS3h3Bb3MXK8 |
Request-Id | req_oZiNhg8yU43Qkj |
Stripe-Version | 2025-06-30.basil |
Vary | Origin |
X-Stripe-Priority-Routing-Enabled | true |
X-Stripe-Routing-Context-Priority-Tier | api-testmode |
X-Wc | ABGHIJ |
Strict-Transport-Security | max-age=63072000; includeSubDom |
Use this endpoint to check the available, pending, and reserved balances of your Stripe account by passing a parameter named `parameter1=test`.
`400` Bad Request
`GET` https://api.stripe.com/v1/balance?parameter1=test
{
"error": {
"code": "parameter_unknown",
"doc_url": "https://stripe.com/docs/error-codes/parameter-unknown",
"message": "Received unknown parameter: parameter1",
"param": "parameter1",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_RJw4l6hmLWtTp7?t=1753226534",
"type": "invalid_request_error"
}
}
Header | Value |
---|---|
Server | nginx |
Date | Tue, 22 Jul 2025 23:22:14 GMT |
Content-Type | application/json |
Content-Length | 343 |
Connection | keep-alive |
Access-Control-Allow-Credentials | true |
Access-Control-Allow-Methods | GET, HEAD, PUT, PATCH, POST, DELETE |
Access-Control-Allow-Origin | * |
Access-Control-Expose-Headers | Request-Id, Stripe-Manage-Version, Stripe-Should-Retry, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required |
Access-Control-Max-Age | 300 |
Cache-Control | no-cache, no-store |
Content-Security-Policy | base-uri 'none'; default-src 'none'; form-action 'none'; frame-ancestors 'none'; img-src 'self'; script-src 'self' 'report-sample'; style-src 'self'; worker-src 'none'; upgrade-insecure-requests; report-uri https://q.stripe.com/csp-violation?q=vlP3P580aBlj1bXnk70rhLWFT_mmeQ5yEUNTD0zVgZyPRabaDLTprVHnX6VD_Qe4ipCB1aZAi8hNYYtx |
Request-Id | req_RJw4l6hmLWtTp7 |
Stripe-Version | 2025-06-30.basil |
Vary | Origin |
X-Stripe-Priority-Routing-Enabled | true |
X-Stripe-Routing-Context-Priority-Tier | api-testmode |
X-Wc | ABGHIJ |
Strict-Transport-Security | max-age=63072000; includeSubDom |
Stripe uses conventional HTTP response codes to indicate the success or failure of an API request. In general: Codes in the 2xx
range indicate success. Codes in the 4xx
range indicate an error that failed given the information provided (e.g., a required parameter was omitted, a charge failed, etc.). Codes in the 5xx
range indicate an error with Stripeโs servers (these are rare).
Some 4xx
errors that could be handled programmatically (e.g., a card is declined) include an error code that briefly explains the error reported.
200 |
OK | Everything worked as expected. |
---|---|---|
400 |
Bad Request | The request was unacceptable, often due to missing a required parameter. |
401 |
Unauthorized | No valid API key provided. |
402 |
Request Failed | The parameters were valid but the request failed. |
403 |
Forbidden | The API key doesnโt have permissions to perform the request. |
404 |
Not Found | The requested resource doesnโt exist. |
409 |
Conflict | The request conflicts with another request (perhaps due to using the same idempotent key). |
424 |
External Dependency Failed | The request couldnโt be completed due to a failure in a dependency external to Stripe. |
429 |
Too Many Requests | Too many requests hit the API too quickly. We recommend an exponential backoff of your requests. |
500, 502, 503, 504 |
Server Errors | Something went wrong on Stripeโs end. (These are rare.) |
api_error |
API errors cover any other type of problem (e.g., a temporary problem with Stripeโs servers), and are extremely uncommon. |
---|---|
card_error |
Card errors are the most common type of error you should expect to handle. They result when the user enters a card that canโt be charged for some reason. |
idempotency_error |
Idempotency errors occur when an Idempotency-Key is re-used on a request that does not match the first requestโs API endpoint and parameters. |
invalid_request_error |
Invalid request errors arise when your request has invalid parameters. |
โ Summary
- Endpoint: /v1/balance [Use this endpoint to check available and pending balances.]
- Method: GET
- Authentication: Bearer token using Stripe Secret Key
- Primary Object: Balance
Author: Snehil Kusum Tiwari