The Stripe dashboard lets us filter different objects based on certain fields. For example, we can filter customers by email, creation date, among other flags.
Now, each Stripe object is identified by a unique hash. Customers, for example, are all identified by a hash of the form cus_xxxxxxx
, as we can see from the customer page in the dashboard.
In the example above, the customer ID is cus_LsuogItdgrLlWW
.
Other types of objects have similar hash ids. Products are all identified as prod_
, payments as xxxxxxx
pi_xxxxx
, and so on.
How can we get a Stripe object using its ID?
The stripe-cli
A very handy tool that lets us retrieve Stripe objects given their ID, is the stripe-cli. You can follow the instructions in the provided link to install it, as well as its excellent tutorial to learn the basics of its utilization.
Once installed and configured, we can get any Stripe object as follows:
$ stripe retrieve <object_type> retrieve <object_id>
<object_type>
can be any of customers
, products
, etc. A complete list of <object_type>
options can be obtained with the following command:
$ stripe resources help
<object_id>
is the hash ID. All object pages in the Stripe Dashboard show the hash ID somewhere. Even better, we can get the ID directly from the object page in the web browser by pressing ctrl + i
.
To get the data of the customer cus_LsuogItdgrLlWW
we saw above, we execute the following command:
$ stripe customers retrieve cus_LsuogItdgrLlWW
It will return the object’s data as a JSON.
{ "id": "cus_LsuogItdgrLlWW", "object": "customer", "account_balance": 0, "address": null, "balance": 0, "created": 1600048580, "currency": null, "default_source": null, "delinquent": false, "description": null, "discount": null, "email": "customer@email.com", "invoice_prefix": "ABCDE", ... }
Stripe’s API documentation has detailed information on the fields that the corresponding object contains.
Stripe Dashboard
The stripe-cli
is very cool and all, but this post is about retrieving objects using the Stripe Dashboard, right?
Unfortunately, I wasn’t able to find a tool built into the dashboard that lets us do it. Please let me know in the comments below if you find one!
However, there’s an easy workaround!
See for example that when you access the page of customer cus_LsuogItdgrLlWW
in the dashboard, the URL will be:
https://dashboard.stripe.com/customers/cus_LsuogItdgrLlWW
Fortunately for us, Stripe object URLs almost always follow the same pattern:
https://dashboard.stripe.com/<object_type>/<object_id>
That means that if we want to visit the page of the product prod_abc12314
, we just need to navigate to:
https://dashboard.stripe.com/products/prod_abc12314
It works similarly for other object types: payments, invoices, coupons, etc!
As a bonus, you can get the list of all objects of a certain type with:
https://dashboard.stripe.com/<object_type>
Kudos to Stripe for this intuitive and simple resource routing!