Inventory & Products | Products | Product Data | Get Products | Filters | by Discount Range

API Guide: Filtering Products by Discount Range

This document provides the details for making an API call to retrieve product data filtered by a discount percentage range.

Get Products by Discount Range

This API call fetches product data filtered by a minimum and/or maximum discount percentage. It can be filtered by setting the discount_min and discount_max parameters.

Understanding Discount Range Filtering

This feature allows you to retrieve products within a specific discount bracket. Using the discount_min and discount_max parameters, you can filter the API response to include only products whose discount percentage falls within the specified range.

  • discount_min only: Returns products with a discount percentage greater than or equal to the specified value (e.g., 10.5 for 10.5%).
  • discount_max only: Returns products with a discount percentage less than or equal to the specified value (e.g., 50.0 for 50%).
  • Both parameters: Returns products whose discount is between discount_min and discount_max (inclusive).
  • Products with no discount (discount = 0) are only returned when discount_min is 0 or not set.
  • Values should be floats (e.g., 10.5, 25.0).

How to Use the Discount Range Filter

Include the discount_min and/or discount_max parameter in your API call.

Use Cases for Discount Range Filtering

  • Sale Pages: Display products with significant discounts (e.g., discount_min=20).
  • Mild Promotions: Show products with small discounts (e.g., discount_min=5&discount_max=15).
  • Clearance Section: Find heavily discounted items (e.g., discount_min=50).
  • Price Comparison Tools: Filter by discount depth for analytics.

Combining with Other Filters

The discount range filter works well in combination with other filters:

  • discount_min + cid — Discounted products in a specific category.
  • discount_max + bid — Products from a brand with limited discounts.
  • discount_min + min_price + max_price — Discounted products within a price range.

Call Examples in Different Languages, discount_min=10.0 and discount_max=50.0


curl -X POST 'https://easycms.fi/public_api/get_products' \
-H 'Authorization1: TOKEN' \
-d 'username=USERNAME&password=PASSWORD&account=ACCOUNT_ID&discount_min=10.0&discount_max=50.0'

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://easycms.fi/public_api/get_products",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => http_build_query(['username' => 'USERNAME', 'password' => 'PASSWORD', 'account' => 'ACCOUNT_ID', 'discount_min' => 10.0, 'discount_max' => 50.0]),
  CURLOPT_HTTPHEADER => array("Authorization1: TOKEN"),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;

import requests
url = "https://easycms.fi/public_api/get_products"
headers = {"Authorization1": "TOKEN"}
payload = {'username': 'USERNAME', 'password': 'PASSWORD', 'account': 'ACCOUNT_ID', 'discount_min': 10.0, 'discount_max': 50.0}
response = requests.post(url, headers=headers, data=payload)
print(response.text)

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://easycms.fi/public_api/get_products"))
    .headers("Authorization1", "TOKEN")
    .POST(HttpRequest.BodyPublishers.ofString("username=USERNAME&password=PASSWORD&account=ACCOUNT_ID&discount_min=10.0&discount_max=50.0"))
    .build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());

const https = require('https');
const data = new URLSearchParams({ 
  username: 'USERNAME', 
  password: 'PASSWORD', 
  account: 'ACCOUNT_ID',
  discount_min: '10.0',
  discount_max: '50.0'
}).toString();
const options = {
  hostname: 'prolasku.fi',
  path: '/public_api/get_products',
  method: 'POST',
  headers: {
    'Authorization1': 'TOKEN',
    'Content-Type': 'application/x-www-form-urlencoded',
    'Content-Length': data.length
  }
};
const req = https.request(options, (res) => {
  let data = '';
  res.on('data', (chunk) => { data += chunk; });
  res.on('end', () => { console.log(data); });
});
req.on('error', (e) => { console.error(e); });
req.write(data);
req.end();

import React, { useEffect, useState } from 'react';
function App() {
  const [productData, setProductData] = useState('');
  useEffect(() => {
    const fetchData = async () => {
      try {
        const response = await fetch('https://easycms.fi/public_api/get_products', {
          method: 'POST',
          headers: {'Authorization1': 'TOKEN', 'Content-Type': 'application/x-www-form-urlencoded'},
          body: new URLSearchParams({username: 'USERNAME', password: 'PASSWORD', account: 'ACCOUNT_ID', discount_min: '10.0', discount_max: '50.0'}).toString()
        });
        const data = await response.text();
        setProductData(data);
      } catch (error) {
        console.error(error);
      }
    };
    fetchData();
  }, []);
  return (
{productData}
); } export default App;

// Kotlin Example using OkHttp for POST request
import okhttp3.OkHttpClient
import okhttp3.FormBody
import okhttp3.Request

fun main() {
    val client = OkHttpClient()

    val formBody = FormBody.Builder()
        .add("username", "USERNAME")
        .add("password", "PASSWORD")
        .add("account", "ACCOUNT_ID")
        .add("discount_min", "10.0")
        .add("discount_max", "50.0")
        .build()

    val request = Request.Builder()
        .url("https://easycms.fi/public_api/get_products")
        .post(formBody)
        .addHeader("Authorization1", "TOKEN")
        .build()

    client.newCall(request).execute().use { response ->
        if (!response.isSuccessful) throw IOException("Unexpected code $response")
        println(response.body?.string())
    }
}

using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
    static async Task Main()
    {
        var token = "TOKEN";
        var content = new FormUrlEncodedContent(new[]
        {
            new KeyValuePair("username", "USERNAME"),
            new KeyValuePair("password", "PASSWORD"),
            new KeyValuePair("account", "ACCOUNT_ID"),
            new KeyValuePair("discount_min", "10.0"),
            new KeyValuePair("discount_max", "50.0")
        });
        using (var httpClient = new HttpClient())
        {
            httpClient.DefaultRequestHeaders.Add("Authorization1", token);
            var response = await httpClient.PostAsync("https://easycms.fi/public_api/get_products", content);
            if (response.IsSuccessStatusCode)
            {
                var responseData = await response.Content.ReadAsStringAsync();
                Console.WriteLine(responseData);
            }
            else
            {
                Console.WriteLine($"Error: {response.StatusCode}");
            }
        }
    }
}