How To Integrate Stripe To Notebook
Here’s something nobody tells you about running a SaaS business: Stripe becomes your best friend and worst nightmare simultaneously. It’s where all your money lives, but getting meaningful insights out of it? That’s a whole different story.
I spent way too many hours exporting CSV files, wrestling with Excel formulas, and manually calculating metrics that should’ve been automated months ago. Revenue trends? Copy-paste into Google Sheets. Customer lifetime value? Another spreadsheet. Failed charges? Don’t even get me started. It was death by a thousand exports.
Then I discovered something that honestly felt too good to be true: Livedocs could connect directly to Stripe’s API and turn all that payment data into actual, usable analysis. No more exports. No more stale data. Just real-time insights that actually helped me make decisions.
Let me show you exactly how I set this up, and why it’s become the single most valuable tool in my tech stack.
You can access the notebook here, use this link.
Or watch the Youtube video here.
The Pain Point
Before we get into the solution, let me paint a picture of my old workflow. Every Monday morning, I’d log into Stripe, click around various tabs, and manually compile a revenue report for our team. It went something like this:
- Export last week’s charges (wait for CSV download)
- Export customer data (another CSV)
- Export subscription changes (you guessed it, CSV)
- Import everything into Google Sheets
- Spend 30 minutes cleaning data formats
- Build pivot tables and formulas
- Create charts manually
- Copy everything into a slide deck
By the time I finished, the data was already outdated. Plus, if anyone asked a follow-up question like “What’s our MRR growth among annual plans specifically?” I’d have to start the whole circus over again.
There had to be a better way.
Enter Livedocs: The API Connection That Changed Everything
Livedocs calls itself a “collaborative data notebook,” but that undersells what it actually does. Think Jupyter notebooks, but with built-in AI, simple data connections, and the ability to work with your team in real time. The game-changer for me? Livedocs has native support for connecting to APIs, including Stripe, which meant I could pull live payment data directly into a notebook and analyze it on the fly.
Setting it up was shockingly simple.
Getting Started: The 10-Minute Setup
I logged into Livedocs and created a new document. Right there in the editor, I clicked the Data panel on the left sidebar. The interface gave me options to connect to databases (PostgreSQL, BigQuery, Snowflake) or upload files, but I needed something more dynamic.
For Stripe, I needed to write a quick Python cell that would authenticate and fetch data via their API. Now, before you panic, I’m not a Python wizard. But Livedocs made this painless because their AI could help me write the code.
I added a Python cell and typed this prompt into the AI assistant:
“Write Python code to connect to Stripe API and fetch all charges from the past 30 days, then convert to a pandas dataframe.”
Boom. The AI generated clean, working code that looked like this:
import stripe
import pandas as pd
from datetime import datetime, timedelta
stripe.api_key = 'sk_test_your_stripe_key_here'
# Fetch charges from last 30 days
charges = stripe.Charge.list(
limit=100,
created={'gte': int((datetime.now() - timedelta(days=30)).timestamp())}
)
# Convert to dataframe
charges_data = []
for charge in charges.auto_paging_iter():
charges_data.append({
'id': charge.id,
'amount': charge.amount / 100, # Convert from cents
'currency': charge.currency,
'status': charge.status,
'customer': charge.customer,
'created': datetime.fromtimestamp(charge.created),
'description': charge.description
})
df_charges = pd.DataFrame(charges_data)
I swapped in my actual Stripe API key (which you can grab from your Stripe Dashboard under Developers > API keys), hit Run, and within seconds I had a dataframe loaded with real payment data. No exports. No downloads. Just live data, right there in my notebook.
Building My First Analysis: Monthly Revenue Breakdown
Once the data was flowing, things got fun. I wanted to answer a simple question: What’s our actual monthly revenue trend over the past six months?
With my old workflow, this would’ve required multiple exports, date calculations in Excel, and probably a mild headache. In Livedocs? I just added another Python cell.
# Group charges by month and sum amounts
df_charges['month'] = df_charges['created'].dt.to_period('M')
monthly_revenue = df_charges.groupby('month')['amount'].sum().reset_index()
# Display
monthly_revenue
The dataframe instantly showed me revenue by month. But I’m a visual person, I needed a chart. So I added a Chart cell below the Python cell and told it to visualize monthly_revenue.
The chart rendered immediately. Clean, professional, and automatically updated whenever I refreshed the data. No manual chart-building in Google Sheets. No copy-pasting values. It just… worked.
Going Deeper: Customer Behavior Patterns
Here’s where Livedocs really started earning its keep. Revenue numbers are great, but I needed to understand customer behavior. Who was paying? Who was churning? What payment methods were failing?
I expanded my Stripe data pull to include customers and subscriptions:
# Fetch customers
customers = stripe.Customer.list(limit=100)
customer_data = []
for customer in customers.auto_paging_iter():
customer_data.append({
'id': customer.id,
'email': customer.email,
'created': datetime.fromtimestamp(customer.created),
'currency': customer.currency
})
df_customers = pd.DataFrame(customer_data)
# Fetch subscriptions
subscriptions = stripe.Subscription.list(limit=100)
sub_data = []
for sub in subscriptions.auto_paging_iter():
sub_data.append({
'id': sub.id,
'customer': sub.customer,
'status': sub.status,
'plan': sub.plan.id if sub.plan else None,
'current_period_end': datetime.fromtimestamp(sub.current_period_end)
})
df_subscriptions = pd.DataFrame(sub_data)
Now I had three interconnected datasets: charges, customers, and subscriptions. The cool part? I could merge them and run analyses that would’ve been impossible with my old CSV exports.
For example, I wanted to identify customers who had multiple failed charges (a red flag for churn):
# Filter for failed charges
failed_charges = df_charges[df_charges['status'] == 'failed']
# Count failed charges per customer
failed_by_customer = failed_charges.groupby('customer').size().reset_index(name='failed_count')
# Merge with customer emails
at_risk = failed_by_customer.merge(df_customers[['id', 'email']], left_on='customer', right_on='id')
at_risk = at_risk.sort_values('failed_count', ascending=False)
at_risk.head(10)
Within seconds, I had a list of our highest-risk customers, people experiencing payment issues who might churn if we didn’t reach out. This insight alone probably saved us thousands in lost revenue.
The AI Assistant
I’ll be honest, I don’t remember all the pandas syntax for data manipulation. Sometimes I’d forget how to merge dataframes or filter by dates. That’s where Livedocs’ AI became invaluable.
Anytime I got stuck, I’d just ask the AI directly in the notebook. For instance:
“Calculate the average customer lifetime value from this subscription data.”
The AI would generate the code, explain what it was doing, and even suggest follow-up analyses. It was like having a data analyst sitting next to me, except it responded in 5 seconds instead of scheduling a meeting for next week.
One time I asked: “Show me payment method distribution, how many customers pay with cards vs. bank transfers?” The AI wrote a groupby query, created a pie chart, and even added labels. I didn’t touch a single line of code.
That’s the magic of Livedocs. It meets you where you are. If you know Python, you can write custom analysis. If you don’t, the AI has your back.
Real-Time Updates
Remember those Monday morning reporting sessions I mentioned? They disappeared completely.
Instead of manually compiling reports, I set up a Livedocs notebook with all my key Stripe metrics:
- Monthly Recurring Revenue (MRR)
- Customer acquisition trends
- Churn rate
- Failed payment alerts
- Average revenue per customer
I saved this notebook and shared it with my team. Now, anyone can open it, click “Run All” at the top, and every cell executes in sequence, pulling fresh data from Stripe and regenerating all the charts and tables.
The whole process takes about 20 seconds. Compare that to my old 2-hour manual workflow, and you can see why I’m never going back.
Plus, Livedocs supports collaborative editing. My co-founder can be in the same notebook, tweaking a chart while I’m adding a new analysis cell. We see each other’s changes in real time, like Google Docs but for data science.
Advanced Use Case: Predictive Revenue Forecasting
Once I got comfortable with the basics, I pushed further. Could I use Stripe data to predict future revenue?
Turns out, yes. With some help from the AI, I pulled historical subscription data and used a simple linear regression model to forecast the next quarter’s MRR:
from sklearn.linear_model import LinearRegression
import numpy as np
# Prepare time series data
monthly_revenue['month_num'] = range(len(monthly_revenue))
X = monthly_revenue[['month_num']].values
y = monthly_revenue['amount'].values
# Train model
model = LinearRegression()
model.fit(X, y)
# Predict next 3 months
future_months = np.array([[len(monthly_revenue)], [len(monthly_revenue)+1], [len(monthly_revenue)+2]])
predictions = model.predict(future_months)
print(f"Predicted revenue for next 3 months: {predictions}")
Was it perfectly accurate? No. But it gave me a data-backed estimate instead of just guessing. And every time I ran the notebook with updated Stripe data, the forecast adjusted automatically.
This kind of analysis used to require a dedicated data science team. Now? Twenty lines of code in Livedocs.
What I Wish I’d Known Earlier
If you’re thinking about doing something similar, here are some lessons I learned the hard way:
Use test mode first.
Stripe has separate API keys for test and live data. Start with test mode (sk_test_...) until you’re confident your queries work correctly. The last thing you want is to accidentally process a refund because you mixed up your API calls.
Pagination matters.
Stripe’s API returns data in batches (usually 100 items at a time). If you have more customers or charges than that, you need to use pagination. Thankfully, Stripe’s Python library has an auto_paging_iter() method that handles this automatically, just use it.
API keys are sensitive.
Don’t hardcode your Stripe secret key directly in the notebook if you’re sharing it. Livedocs supports environment variables, so you can store your key securely and reference it as os.getenv('STRIPE_SECRET_KEY').
Rate limits exist.
Stripe’s API has rate limits (usually pretty generous, but they exist). If you’re pulling massive amounts of data, add some error handling or slow down your requests slightly.
Timestamps are in Unix format.
Stripe returns dates as Unix timestamps (seconds since 1970). Convert them to Python datetime objects immediately for easier manipulation: datetime.fromtimestamp(charge.created).
The Bigger Picture
What I love most about using Livedocs with Stripe isn’t just the technical convenience, it’s the mental shift it creates.
Before, I saw data analysis as this heavyweight task that required dedicated time blocks and lots of coffee. Now? I casually open my Livedocs notebook whenever I have a question about our business. How many customers signed up this week? What’s our average transaction size? Are we seeing more refunds than usual?
Every question gets answered in seconds, not hours. And because the notebook is live and collaborative, my whole team can do the same thing. Our head of customer success pulls churn data. Our marketing person analyzes acquisition costs. Everyone’s looking at the same real-time source of truth.
That’s powerful.
Plus, Livedocs’ free plan includes $10 of AI usage, which was plenty to get started and build my initial Stripe analyses. Once we saw the value (which took about a day), upgrading to Pro at $20/month was a no-brainer. Compare that to hiring a full-time analyst or subscribing to expensive BI tools, and the ROI is ridiculous.
What’s Next: Expanding Beyond Stripe
Now that I’ve got Stripe data flowing smoothly into Livedocs, I’m connecting other tools too:
- Google Analytics (website traffic and conversion data)
- Intercom (support ticket trends)
- PostgreSQL (our app’s user activity database)
The goal is to build a unified analytics hub where everything lives in one place. Stripe revenue data next to customer support metrics next to user engagement patterns. All updated in real time, all accessible to my team, all driven by AI when we need help.
It’s like having a custom analytics platform built exactly how we need it, without spending six figures on enterprise software.
Final Thoughts
You don’t need to build a complex data pipeline on day one. Start with one simple question you need answered regularly, mine was “What did we make last month?”, and build a Livedocs notebook that answers it using Stripe’s API.
Once that’s working, add another question. Then another. Before you know it, you’ll have a comprehensive analytics system that actually gets used instead of collecting dust in some forgotten bookmark folder.
The barrier to entry is incredibly low. If you have a Stripe account and can copy-paste Python code (or let AI write it for you), you’re 90% of the way there. The remaining 10% is just clicking Run and watching your data come to life.
Trust me, your future self will thank you when someone asks “What’s our churn rate this quarter?” and you can pull up the answer in 10 seconds instead of scrambling through spreadsheets for two hours.
Get started with Livedocs and build your first live notebook in minutes.
- 💬 If you have questions or feedback, please email directly at a[at]livedocs[dot]com
- 📣 Take Livedocs for a spin over at livedocs.com/start. Livedocs has a great free plan, with $10 per month of LLM usage on every plan
- 🤝 Say hello to the team on X and LinkedIn
Stay tuned for the next article!

