Published
Edited
Sep 21, 2021
9 forks
6 stars
Insert cell
Insert cell
Insert cell
data = hasApiKey
? stripe("/v1/balance_transactions")
: FileAttachment("sample-transactions.json").json()
Insert cell
Plot.plot({
y: {
tickFormat: "$.2",
label: "Revenue"
},
color: {
domain: [-1, 1],
scheme: "RdBu"
},
marks: [
Plot.ruleY([0]),
Plot.rectY(
data,
Plot.binX(
{ y: "sum" },
{
x: (d) => new Date(d.created * 1000), // Stripe gives dates as seconds since Unix epoch
y: (d) => d.net / 100, // Stripe gives transaction amounts in cents
fill: (d) => Math.sign(d.net), // Inflows blue, outflows red
thresholds: d3.utcWeek // Bin by week
}
)
)
]
})
Insert cell
import {stripe, hasApiKey} from "@observablehq/stripe-api-helpers"
Insert cell
// For a notebook to access Secrets, it must statically reference one; this cell grants Secret access to the notebook from which we import the GitHub API helpers. `undefined &&` prevents the Secret from appearing in plaintext in the Inspector.
undefined && Secret("STRIPE_API_KEY")
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more