Shelves | Get Shelves

Getting Shelf Data

This document outlines the procedure for making API calls to retrieve shelf data from https://easycms.fi/public_api/get_shelves/. Utilize various parameters to filter and customize your data retrieval, including by location_id.

Shelves Data Retrieval

Fetch shelf data effectively using the below API call. Apply the IN, NOT_IN, or location_id parameters as an array or a single integer to filter results according to your specific needs.

Endpoint and Method

  • Endpoint: https://easycms.fi/public_api/get_shelves/
  • Method: POST

Parameters | Payload

Each parameter can be used individually or in combination to refine your data retrieval:

  • TOKEN (api_key): Your unique API key for authentication. How to Create API Credentials.
  • username: Your login username.
  • password: Your login password.
  • account: Your specific account ID.
  • Pagination: To manage data effectively, this endpoint supports fetching up to 50 shelves at a time.
    • start - Specify the starting point from which to begin fetching shelves.
    • limit - Control the number of shelves returned in a single request. The maximum limit is 50, but you can opt for a smaller number based on your needs.
  • Filters:
    • IN - Specify Shelf IDs to include specific shelves (optional, array or single integer).
    • NOT_IN - Specify Shelf IDs to exclude specific shelves (optional, array or single integer).
    • location_id - Specify a single Location ID to fetch shelves related to a specific location.



Call Examples in Different Languages


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

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

import requests
url = "https://easycms.fi/public_api/get_shelves"
headers = {"Authorization1": "TOKEN"}
payload = {'username': 'USERNAME', 'password': 'PASSWORD', 'account': 'ACCOUNT_ID'}
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_shelves"))
    .headers("Authorization1", "TOKEN")
    .POST(HttpRequest.BodyPublishers.ofString("username=USERNAME&password=PASSWORD&account=ACCOUNT_ID"))
    .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'
}).toString();
const options = {
  hostname: 'prolasku.fi',
  path: '/public_api/get_shelves',
  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 [categoryData, setCategoryData] = useState('');
  useEffect(() => {
    const fetchData = async () => {
      try {
        const response = await fetch('https://easycms.fi/public_api/get_shelves', {
          method: 'POST',
          headers: {'Authorization1': 'TOKEN', 'Content-Type': 'application/x-www-form-urlencoded'},
          body: new URLSearchParams({username: 'USERNAME', password: 'PASSWORD', account: 'ACCOUNT_ID'}).toString()
        });
        const data = await response.text();
        setCategoryData(data);
      } catch (error) {
        console.error(error);
      }
    };
    fetchData();
  }, []);
  return (
{categoryData}
); } 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")
        .build()

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

Handling Endpoint Results

When you make a request to the endpoint, you receive a JSON response containing various keys and values. Here's an explanation of the response keys and their meanings:


- `shelf_id`: Shelf ID (String) - A unique identifier for each shelf.
- `location_id`: Location ID (String) - The identifier of the location where the shelf is situated.
- `cr_shelf_id`: CR Shelf ID (String) - A unique identifier, typically in UUID format, associated with the shelf.
- `shelf_number`: Shelf Number (Integer) - A numerical identifier for the shelf.
- `shelf_name`: Shelf Names (Object) - An object containing the name of the shelf in different languages.
  - `fi`: Shelf name in Finnish (String).
  - `en_gb`: Shelf name in English (Great Britain) (String).
  - `zh`: Shelf name in Chinese (String).
  - `vi`: Shelf name in Vietnamese (String).
- `parent_id`: Parent Shelf ID (Integer) - The identifier of the parent shelf, if applicable.
- `visible`: Visibility Status (String) - Indicates whether the shelf is visible ("1") or not ("0").
    

{
    "INFO": {
        "start": 0,
        "limit": 50,
        "count": 5,
        "total_count": "5",
        "tip": "You may pass the table's main column identifier ex: city_id for tbl_cities, pid for tbl_products, cid for tbl_categories etc... to make a request for a single specific id from your query. EXAMPLE PARAM: city_id = 2 when sending the request for \"get_cities\" "
    },
    "OUTPUT": [
        {
            "shelf_id": "84",
            "location_id": "13",
            "cr_shelf_id": "8695104b-7164-4cc4-a24b-82b84b001a5b",
            "shelf_number": 0,
            "shelf_name": {
                "fi": "shelf_1",
                "en_gb": "shelf_1",
                "zh": "shelf_1",
                "vi": "shelf_1"
            },
            "parent_id": 0,
            "visible": "1"
        },
        {
            "shelf_id": "65",
            "location_id": "9",
            "cr_shelf_id": "0",
            "shelf_number": "1",
            "shelf_name": {
                "en_gb": "Shelf+1",
                "fi": "Shelf+1"
            },
            "parent_id": 0,
            "visible": "1"
        },
        {
            "shelf_id": "66",
            "location_id": "9",
            "cr_shelf_id": "0",
            "shelf_number": "2",
            "shelf_name": {
                "en_gb": "Shelf+2",
                "fi": "Shelf+2"
            },
            "parent_id": 0,
            "visible": "1"
        },
        {
            "shelf_id": "67",
            "location_id": "10",
            "cr_shelf_id": "70098f66-af44-40fe-9831-f13dba2e0309",
            "shelf_number": "3",
            "shelf_name": {
                "en_gb": "H+Shelf+1",
                "fi": "H+Shelf+1"
            },
            "parent_id": 0,
            "visible": "1"
        },
        {
            "shelf_id": "68",
            "location_id": "11",
            "cr_shelf_id": "f692f321-bc75-4e2a-a150-4cbd0c628761",
            "shelf_number": "4",
            "shelf_name": {
                "en_gb": "T+shelf+1",
                "fi": "T+shelf+1"
            },
            "parent_id": 0,
            "visible": "1"
        }
    ]
}
    

Error Handling

Here are the possible error messages and their meanings:

  • UN-AUTHORIZED - _user_name_password_is_set_but_wrong_value!: Incorrect username or password.
  • this_account_does_not_exist_or_your_credentials_do_not_match_this_account: The account doesn't exist or mismatched credentials.
  • UN-AUTHORIZED - header is set but the header value is not correct!: Incorrect authorization header value.
  • Maximum query size is 50 rows per query: Exceeded maximum limit of 50 rows per query.