stripe-streams
A library for streaming Stripe API calls
npm install stripe-streams
Reasoning
Stripe's API paginates the results. You can fetch a maximum of 100 items in a single query, after which you need to requery with the starting_after
parameter set to the last item from the previous query.
This library allows you to stream results from the Stripe API without having to worry about pagenation. It will be taken care of for you.
For example, to stream a list of customers, you can call:
var CustomerStream = CustomerStream;var stripe = processenvSTRIPE_KEY; stripe ;
This will fetch all customers from Stripe and return each customer object as an object in an objectstream.
Parameters
It is also possible to pass query parameters to Stripe:
var CustomerStream = CustomerStream;var stripe = processenvSTRIPE_KEY; // Fetch all new customers in the last day...stripe created: gt: Math - 86400 ;
Pipes
Stripe streams are fully compliant node streams, so you can transform them, pipe them to other streams, etc
var BalanceHistoryStream = BalanceHistoryStream;var stripe = processenvSTRIPE_KEY;var csv = ;
API
The API supports the following streams:
Stream | Stripe API |
---|---|
BalanceHistoryStream | https://stripe.com/docs/api/node#balance_history |
ChargeStream | https://stripe.com/docs/api/node#list_charges |
CouponStream | https://stripe.com/docs/api/node#list_coupons |
CustomerStream | https://stripe.com/docs/api/node#list_customers |
InvoiceItemStream | https://stripe.com/docs/api/node#list_invoiceitems |
InvoiceStream | https://stripe.com/docs/api/node#invoices |
PlanStream | https://stripe.com/docs/api/node#list_plans |
RecipientStream | https://stripe.com/docs/api/node#list_recipients |
TransferStream | https://stripe.com/docs/api/node#list_transfers |
Licence
License The MIT License (MIT)
Copyright (c) 2014, Andrew Newdigate
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.