Stock Types | Get Stock Types | Filter By Stock Type IDs

API Guide: Filtering Stock Types by Stock Type ID(s)

This document provides the details for making an API call to retrieve stock types by filtering by stock type ID(s).

Get Stock Types by Stock Type ID

This API call fetches stock type data. It can be filtered by using a single stid (stock type ID) or multiple stock_type_id through the IN[] parameter.

Understanding Stock Type ID Filtering

This functionality allows for the retrieval of specific stock types based on their unique IDs. You can filter for a single stock type using stid or for multiple stock types using IN[] with multiple stid values.

How to Use Stock Type ID Filter

  • Single Stock Type ID: To filter for a single stock type, include stid=integer in your API call, where integer is the stock type ID.
  • Multiple Stock Type IDs: To filter for multiple stock types, use IN=array(integer,integer, ...) for each stock type ID you wish to include in the filter. Insert stock_type_id IN=array(stid,stid, ...) for each additional stock type ID.

Use Cases for Stock Type ID Filtering

  • Specific Stock Type Retrieval: Retrieve details for a specific stock type or a set of stock types by their IDs.
  • Inventory Management: Manage and categorize your inventory by filtering specific stock types.
  • Data Analysis: Analyze specific stock types based on their IDs for inventory management, supply chain optimization, or sales analysis.

For detailed instructions on how to format your request and handle the API responses, please refer to the API documentation.

Call Examples in Different Languages

Here's an example of making a POST request to get_stock_types with different programming languages:


curl -X POST 'https://easycms.fi/public_api/get_stock_types' \
-H 'Authorization1: TOKEN' \
-d 'username=USERNAME&password=PASSWORD&account=ACCOUNT_ID' \
-d 'IN[]=64' \
-d 'IN[]=65'

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

import requests
url = "https://easycms.fi/public_api/get_stock_types"
headers = {"Authorization1": "TOKEN"}
payload = {'username': 'USERNAME', 'password': 'PASSWORD', 'account': 'ACCOUNT_ID', 'IN': [64, 65]}
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_stock_types"))
    .headers("Authorization1", "TOKEN")
    .POST(HttpRequest.BodyPublishers.ofString("username=USERNAME&password=PASSWORD&account=ACCOUNT_ID&IN[]=64&IN[]=65"))
    .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',
  'IN[]': [64, 65]
}).toString();
const options = {
  hostname: 'prolasku.fi',
  path: '/public_api/get_stock_types',
  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_stock_types', {
          method: 'POST',
          headers: {'Authorization1': 'TOKEN', 'Content-Type': 'application/x-www-form-urlencoded'},
          body: new URLSearchParams({username: 'USERNAME', password: 'PASSWORD', account: 'ACCOUNT_ID', 'IN[]': [64, 65]}).toString()
        });
        const data = await response.text();
        setProductData(data);
      } catch (error) {
        console.error(error);
      }
    };
    fetchData();
  }, []);
  return (
{productData}
); } export default App;

// Kotlin example requires using a third-party library like OkHttp for POST requests with a body
// 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("IN[]", "64")
        .add("IN[]", "65")
        .build()

    val request = Request.Builder()
        .url("https://easycms.fi/public_api/get_stock_types")
        .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("IN[]", "64"),
            new KeyValuePair("IN[]", "65")
        });
        using (var httpClient = new HttpClient())
        {
            httpClient.DefaultRequestHeaders.Add("Authorization1", token);
            var response = await httpClient.PostAsync("https://easycms.fi/public_api/get_stock_types", content);
            if (response.IsSuccessStatusCode)
            {
                var responseData = await response.Content.ReadAsStringAsync();
                Console.WriteLine(responseData);
            }
            else
            {
                Console.WriteLine($"Error: {response.StatusCode}");
            }
        }
    }
}