Inventory & Products | Products | Product Data | Get Products | Filters | by Customer Pricing

API Guide: Filtering Products by Customer-Specific Pricing

This document provides the details for making an API call to retrieve product data with customer-specific pricing applied.

Get Products with Customer Pricing

This API call fetches product data with pricing adjusted for a specific customer. Pass the customer_id parameter to apply customer-specific discounts and locked prices.

Understanding Customer-Specific Pricing

When a customer_id is provided, the API retrieves the customer's discount percentage and any negotiated product pricing. The response will contain prices that reflect the customer's specific deal, rather than the standard list prices.

  • Customer discount: If the customer has a global discount percentage, it is applied to all products. A negative discount means the customer gets a markup (higher price).
  • Locked prices: If the customer has individually negotiated prices for specific products (locked prices), those override both the standard price and the global discount.
  • Price fields affected: price, price_gross, price_net_after_discount, price_gross_after_discount, and discount in the response will all reflect the customer-specific values.

How Customer Pricing Works

  1. The API looks up the customer's global discount using customer::get_customer().
  2. It retrieves any product-specific pricing using customer::get_customer_pricing().
  3. For each product, it applies the customer-specific logic:
    • If the customer has a locked price for a product, that price is used.
    • If the customer has a global discount but no locked price, the discount is applied to the standard price.
    • If the customer's discount would result in a negative discount (price higher than standard), the discount is set to 0 and the locked price is used.

How to Use the Customer Pricing Filter

Include the customer_id parameter as an integer in your API call.

Use Cases for Customer Pricing

  • B2B Portals: Show customers their negotiated prices when they log in.
  • Mobile Apps: Display personalized pricing in customer-facing apps.
  • Quote Generation: Fetch accurate pricing for a specific customer to generate quotes.
  • Price Validation: Verify that customer-specific prices are correctly configured.

Combining with Other Filters

  • customer_id + cid — Customer-specific pricing for products in a category.
  • customer_id + product_name — Search for products with customer pricing applied.
  • customer_id + include_costs=1 — Get full cost and margin data alongside customer prices.

Call Examples in Different Languages, customer_id=123


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

$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', 'customer_id' => 123]),
  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', 'customer_id': 123}
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&customer_id=123"))
    .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',
  customer_id: '123'
}).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', customer_id: '123'}).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("customer_id", "123")
        .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("customer_id", "123")
        });
        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}");
            }
        }
    }
}