Inventory & Products | Products | Product Data | Get Products | Filters | by Supplier ID

API Guide: Filtering Products by Supplier

This document provides the details for making an API call to retrieve product data filtered by supplier.

Get Products by Supplier

This API call fetches product data filtered by supplier ID(s). It can be filtered by setting the supplier_id or supplier_id[] parameter.

Understanding Supplier Filtering

This feature allows you to retrieve products from a specific supplier or set of suppliers. Using the supplier_id parameter, you can filter the API response to include only products associated with the specified supplier(s).

  • Single supplier: Pass supplier_id as an integer (e.g., supplier_id=5).
  • Multiple suppliers: Pass supplier_id[] as an array of integers.
  • Standard products: For products where multi_code_supplier is 0 or NULL, the filter checks the supplier_id column directly on tbl_products.
  • Multi-code supplier products: For products where multi_code_supplier is 1, the filter also searches in the tbl_products_multi table for matching supplier IDs.

Supplier + Location Combined Filter

When both supplier_id and location_id are passed together, the filter behavior is enhanced:

  • For products with multi_code_supplier=1, BOTH the supplier_id AND location_id must match in the same row of tbl_products_multi.
  • This ensures accurate results for products that have different suppliers per location.

How to Use the Supplier Filter

Include the supplier_id parameter (integer or array) in your API call.

Use Cases for Supplier Filtering

  • Supplier Catalog: Display all products from a specific supplier.
  • Procurement Reports: Generate reports filtered by supplier.
  • Multi-Supplier Management: Filter products from multiple suppliers at once.
  • Location-Specific Sourcing: Find products from a supplier at a specific location.

Combining with Other Filters

  • supplier_id + location_id — Products from a supplier at a specific location.
  • supplier_id + cid — Products from a supplier in a specific category.
  • supplier_id + min_price + max_price — Products from a supplier within a price range.

Call Examples in Different Languages, supplier_id=1


# Filter by single supplier
curl -X POST 'https://easycms.fi/public_api/get_products' \
-H 'Authorization1: TOKEN' \
-d 'username=USERNAME&password=PASSWORD&account=ACCOUNT_ID&supplier_id=1'

# Filter by multiple suppliers
curl -X POST 'https://easycms.fi/public_api/get_products' \
-H 'Authorization1: TOKEN' \
-d 'username=USERNAME&password=PASSWORD&account=ACCOUNT_ID&supplier_id[]=1&supplier_id[]=3&supplier_id[]=5'

# Filter by supplier at a specific location
curl -X POST 'https://easycms.fi/public_api/get_products' \
-H 'Authorization1: TOKEN' \
-d 'username=USERNAME&password=PASSWORD&account=ACCOUNT_ID&supplier_id=1&location_id=4'

$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',
    'supplier_id' => [1, 3, 5]  // Multiple suppliers as array
  ]),
  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', 'supplier_id': [1, 3, 5]}
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&supplier_id[]=1&supplier_id[]=3"))
    .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',
  'supplier_id[]': ['1', '3', '5']
}).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', 'supplier_id': '1'}).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("supplier_id", "1")
        .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("supplier_id[]", "1"),
            new KeyValuePair("supplier_id[]", "3")
        });
        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}");
            }
        }
    }
}