Getting started with the Search API

mattling_dev - Jun 8 '22 - - Dev Community

What you’ll learn

If you’ve worked with the Stripe API before, you know that you can retrieve your resources like Customers and Payment Intents by using list API endpoints and then paging through the resulting data. You may have even used the really useful auto-pagination features — that are included in all of our officially supported client libraries — to page and filter objects to be used in your system.

In this episode you’ll learn how to leverage the new Search API and its comprehensive query language to query the API directly for your Stripe resources. This new API enables you to build complex interfaces to your data. For example, you might want to build a search tool for listing failed Charges, or Customers with a specific email address for support cases.

Now for searchable resources, you can issue a search query in one API call and retrieve the objects you’re interested in. Here’s a simple example in Ruby:

results = Stripe::PaymentIntent.search(query: 'amount:1000')
results.each do |result|
  p %(#{result.id} #{result.amount} #{result.currency})
end
Enter fullscreen mode Exit fullscreen mode

Auto-pagination is also available on search results using our client libraries.

Prerequisites

If you’d like to follow along, you’ll need a Stripe account which you can sign up for here.

Table of contents

What to watch next

To learn about auto-pagination there is a list of videos in many languages on our YouTube channel.

About the author

Matthew Ling

Matthew Ling (@mattling_dev) is a Developer Advocate at Stripe. Matt loves to tinker with new technology, adores Ruby and coffee and also moonlighted as a pro music photographer. His photo site is at matthewling.com and developer site is at mattling.dev.

Stay connected

In addition, you can stay up to date with Stripe in a few ways:

📣 Follow us on Twitter
💬 Join the official Discord server
📺 Subscribe to our Youtube channel
📧 Sign up for the Dev Digest

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player