Back to Stripe Programming Languages Index
Python Stripe REST API Examples
Retrieve a Balance Transaction
Retrieves the balance transaction with the given ID.
Retrieves the current account balance, based on the authentication that was used to make the request.
List Balance History
Returns a list of transactions that have contributed to the Stripe account balance (e.g., charges, transfers, and so forth). The transactions are returned in sorted order, with the most recent transactions appearing first.
Create a Charge
To charge a credit card, you create a Charge object. If your API key is in test mode, the supplied payment source (e.g., card) won't actually be charged, though everything else will occur as if in live mode. (Stripe assumes that the charge would have completed successfully).
Retrieve a charge
Retrieves the details of a charge that has previously been created.
Update a charge
Updates the specified charge by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
Capture a Charge
Capture the payment of an existing, uncaptured, charge. This is the second half of the two-step payment flow, where first you created a charge with the capture option set to false.
List all Charges
Returns a list of charges you’ve previously created. The charges are returned in sorted order, with the most recent charges appearing first.
Create a Customer
Creates a new customer object.
Retrieve a Customer
Retrieves the details of an existing customer. You need only supply the unique customer identifier that was returned upon customer creation.
Update a Customer
Updates the specified customer by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
Delete a Customer
Permanently deletes a customer. It cannot be undone. Also immediately cancels any active subscriptions on the customer.
List all Customers
Returns a list of your customers. The customers are returned sorted by creation date, with the most recent customers appearing first.
Retrieve a Dispute
Retrieves the dispute with the given ID.
Update a Dispute
Submit evidence for a dispute with the given ID.
Close a Dispute
Closing the dispute for a charge indicates that you do not have any evidence to submit and are essentially ‘dismissing’ the dispute, acknowledging it as lost
List all Disputes
Returns a list of your disputes.
List all Events
List events, going back up to 30 days.
Retrieve an Event
Retrieves the details of an event. Supply the unique identifier of the event, which you might have received in a webhook.
Create a File Upload
Uploads a file to Stripe.
Retrieve a File Upload
Retrieves the details of an existing file object. Supply the unique file upload ID from a file creation request, and Stripe will return the corresponding transfer information.
List all File Uploads
Returns a list of the files that you have uploaded to Stripe. The file uploads are returned sorted by creation date, with the most recently created file uploads appearing first.
Create a Payout
To send funds to your own bank account, you create a new payout object.
Retrieve a Payout
Retrieves the details of an existing payout. Supply the unique payout ID from either a payout creation request or the payout list, and Stripe will return the corresponding payout information.
Update a Payout
Updates the specified payout by setting the values of the parameters passed. Any parameters not provided will be left unchanged. This request accepts only the metadata as arguments.
List all Payouts
Returns a list of existing payouts sent to third-party bank accounts or that Stripe has sent you. The payouts are returned in sorted order, with the most recently created payouts appearing first.
Cancel a Payout
A previously created payout can be canceled if it has not yet been paid out.
Create a Refund
Creates a new refund to refund a charge that has previously been created but not yet refunded.
Retrieve a Refund
Retrieves the details of an existing refund.
Update a Refund
Updates the specified refund by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
List all Refunds
Returns a list of all refunds you’ve previously created.
Create a Card Token
Creates a single use token that wraps the details of a credit card. This token can be used in place of a credit card dictionary with any API method.
Create a Bank Account Token
Creates a single use token that wraps the details of a bank account. This token can be used in place of a bank account dictionary with any API method.
Create a PII Token
Creates a single use token that wraps the details of personally identifiable information (PII). This token can be used in place of a personal_id_number in the Account Update API method. These tokens can only be used once.
Retrieve a Token
Retrieves the token with the given ID.
Create a Bank Account
Creates a new bank account object.
Retrieve a Bank Account
Retrieve details about a specific bank account stored on the Stripe account.
Update a Bank Account
Updates the metadata, account_holder_name, and account_holder_type of a bank account belonging to a Customer. Other bank account details are not editable by design.
Verify a Bank Account
Verifies a customer's bank account.
Delete a Bank Account
Deletes a customer's bank account.
List all Bank Accounts
List bank accounts belonging to a customer.
Create a Card
Creates a new credit card belonging to a customer.
Retrieve a Card
Retrieve details about a specific card stored on the customer or recipient.
Update a Card
Updates only some card details, like the billing address or expiration date, you can do so without having to re-enter the full card details.
Delete a Card
Deletes a customer credit card.
List all Cards
List the cards belonging to a customer or recipient.
Create a Source
Creates a new source object.
Retrieve a Source
Retrieves an existing source object. Supply the unique source ID from a source creation request and Stripe will return the corresponding up-to-date source object information.
Update a Source
Updates the specified source by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
Attach a Source
Attaches a Source object to a Customer. The source must be in a chargeable state.
Detach a Source
Detaches a Source object from a Customer. The status of a source is changed to consumed when it is detached and it can no longer be used to create a charge.
Create a Coupon
Creates a coupon object.
Retrieve a Coupon
Retrieves the coupon with the given ID.
Update a Coupon
Updates the metadata of a coupon. Other coupon details (currency, duration, amount_off) are, by design, not editable.
Delete a Coupon
Deletes a coupon.
List all Coupons
Returns a list of your coupons.
Delete a Customer Discount
Removes the currently applied discount on a customer.
Delete a Customer Subscription Discount
Removes the currently applied discount on a subscription.
Create an Invoice
Creates a customer invoice object.
Retrieve an Invoice
Retrieves the invoice with the given ID.
Retrieve an Invoice's Line Items
Retrieves the line items for a given invoice.
Retrieve an Upcoming Invoice
Retrieves an upcoming invoice.
Update an Invoice
Updates an invoice.
Pay an Invoice
Attempts payment on an invoice out of the normal collection schedule.
List all Invoices
Attempts payment on an invoice out of the normal collection schedule.