Filtering Stories by Defining a Value Range
In a common shop content structure implementation, a simple price range products filter is often necessary. A single filter_query can be crafted to retrieve products that exceed or fall below a specified price point. In this scenario, the gt_float and lt_float filters are combined to obtain all products within a given price range.
Example Request and Response
Section titled “Example Request and Response”The following example demonstrates how to receive products (stories of that story type) with a price value between 200 and 300.
curl "https://api.storyblok.com/v2/cdn/stories\?starts_with=products\&token=ask9soUkv02QqbZgmZdeDAtt\&filter_query%5Bprice%5D%5Blt_float%5D=300\&filter_query%5Bprice%5D%5Bgt_float%5D=200"// storyblok-js-client@>=7, node@>=18import Storyblok from "storyblok-js-client";
const storyblok = new Storyblok({ accessToken: "ask9soUkv02QqbZgmZdeDAtt",});
try { const response = await storyblok.get('cdn/stories', { "starts_with": "products", "filter_query[price][lt_float]": "300", "filter_query[price][gt_float]": "200" }) console.log({ response })} catch (error) { console.log(error)}$client = new \Storyblok\Client('YOUR_STORYBLOK_SPACE_ACCESS_TOKEN');
$client->getStories([ "starts_with" => "products", "filter_query[price][lt_float]" => "300", "filter_query[price][gt_float]" => "200"])->getBody();HttpResponse<String> response = Unirest.get("https://api.storyblok.com/v2/cdn/stories?starts_with=products&token=ask9soUkv02QqbZgmZdeDAtt&filter_query%5Bprice%5D%5Blt_float%5D=300&filter_query%5Bprice%5D%5Bgt_float%5D=200") .asString();var client = new RestClient("https://api.storyblok.com/v2/cdn/stories?starts_with=products&token=ask9soUkv02QqbZgmZdeDAtt&filter_query%5Bprice%5D%5Blt_float%5D=300&filter_query%5Bprice%5D%5Bgt_float%5D=200");var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);import requests
url = "https://api.storyblok.com/v2/cdn/stories"
querystring = {"starts_with":"products","token":"ask9soUkv02QqbZgmZdeDAtt","filter_query[price][lt_float]":"300","filter_query[price][gt_float]":"200"}
payload = ""headers = {}
response = requests.request("GET", url, data=payload, headers=headers, params=querystring)
print(response.text)require 'storyblok'client = Storyblok::Client.new(token: 'YOUR_TOKEN')
client.stories({:params => { "starts_with" => "products", "filter_query[price][lt_float]" => "300", "filter_query[price][gt_float]" => "200"}})// .package(url: "https://github.com/storyblok/storyblok-swift.git", from: "1.1.0")// Requires a `Block` content model — see https://www.storyblok.com/docs/quickstarts/apple-platforms/content-modelinglet client = StoryblokClient( library: Block.self, accessToken: "ask9soUkv02QqbZgmZdeDAtt", version: .published, region: .eu)
let stories: Page<Story<Block.Product>>? = try await client .stories { @Sendable (query: inout StoriesQuery<Block.Product>) in query.startsWith = "products" query.filter { $0.price.asDecimal < 300 $0.price.asDecimal > 200 } } .last() .values .first { @Sendable _ in true }
print(stories!)// implementation("com.storyblok:content-api-client:0.7.1")// Requires a `Product` component model — see https://www.storyblok.com/docs/quickstarts/android/content-modelingval client = StoryblokClient( accessToken = "ask9soUkv02QqbZgmZdeDAtt", version = Published,)
val stories = client .stories<Product> { startsWith = "products" filter { Product::price lessThan 300.0 Product::price greaterThan 200.0 } } .flow .asItemSnapshotListFlow() .first()
println(stories){ "stories": [ { "name": "Coat", "created_at": "2018-12-10T17:50:34.547Z", "published_at": "2026-11-03T10:00:23.774Z", "updated_at": "2026-11-03T10:00:23.787Z", "id": 461933, "uuid": "0186a027-4f04-4750-b743-8855ad4e71d4", "content": { "_uid": "baa8057c-a928-4fda-b322-9499a081a9c9", "link": { "id": "", "url": "", "linktype": "story", "fieldtype": "multilink", "cached_url": "" }, "name": "Coat", "image": "//a.storyblok.com/f/44203/5616x3744/8cff02e5d6/coat.jpg", "price": "279", "featured": true, "component": "product", "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. In erat mauris, faucibus quis pharetra sit amet, pretium ac libero. Etiam vehicula eleifend bibendum." }, "slug": "coat", "full_slug": "products/coat", "sort_by_date": null, "position": -10, "tag_list": [ "red", "sale" ], "is_startpage": false, "parent_id": 461931, "meta_data": null, "group_id": "d17c3137-d695-45f0-a418-bce81b148567", "first_published_at": "2018-12-10T17:50:47.000Z", "release_id": null, "lang": "default", "path": null, "alternates": [], "default_full_slug": null, "translated_slugs": null } ], "cv": 1793700142, "rels": [], "links": []}Was this page helpful?
This site uses reCAPTCHA and Google's Privacy Policy (opens in a new window).Terms of Service (opens in a new window) apply.
Get in touch with the Storyblok community