Created
October 14, 2025 00:04
-
-
Save coolov/95955f2076f0bd3fca5477b3f036f89c to your computer and use it in GitHub Desktop.
stripe subscriber data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # bash script for exporting subscriber data from stripe, using the stripe cli: | |
| # https://docs.stripe.com/stripe-cli | |
| # make sure you sign in first: | |
| # https://docs.stripe.com/stripe-cli/install#login-account | |
| echo "id,name,shipping.name,shipping.address.city,shipping.address.country,shipping.address.line1,shipping.address.line2,shipping.address.postal_code,shipping.address.state,subscriptions.count,subscriptions.status,subscriptions.plan.product" | |
| STARTING_AFTER="" | |
| while :; do | |
| if [ -z "$STARTING_AFTER" ]; then | |
| RESPONSE=$(stripe customers list --live --expand "data.subscriptions" --limit 100) | |
| else | |
| RESPONSE=$(stripe customers list --live --expand "data.subscriptions" --limit 100 --starting-after "$STARTING_AFTER") | |
| fi | |
| echo $RESPONSE | \ | |
| jq -r '.data[] | [.id, .name, .shipping.name, .shipping.address.city, .shipping.address.country, .shipping.address.line1, .shipping.address.line2, .shipping.address.postal_code, .shipping.address.state, (.subscriptions.data | length), .subscriptions.data[0].status, .subscriptions.data[0].plan.product] | @csv' | |
| HAS_MORE=$(echo "$RESPONSE" | jq -r '.has_more') | |
| if [ "$HAS_MORE" != "true" ]; then | |
| break | |
| fi | |
| STARTING_AFTER=$(echo $RESPONSE | jq -r ".data[-1].id") | |
| done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment