Languages | Get Languages

Getting Language Data

This document outlines the procedure for making API calls to retrieve language data from https://easycms.fi/public_api/get_languages/. Utilize various parameters to filter and customize your data retrieval.

Languages Data Retrieval

Fetch language data effectively using the below API call.

Endpoint and Method

  • Endpoint: https://easycms.fi/public_api/get_languages/
  • 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 data in batches.
  • Parameters:
    • start - Specify the starting point from which to begin fetching data.
    • limit - Control the number of items returned in a single request. Adjust this parameter based on your needs.

For further assistance or API integration support, please refer to our API Support or contact our technical support team.



Call Examples in Different Languages


curl -X POST 'https://easycms.fi/public_api/get_languages' \
-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_languages",
  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_languages"
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_languages"))
    .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_languages',
  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_languages', {
          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_languages")
        .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_languages", 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:


- `id`: Language ID (Integer) - This is the unique identifier for each language setting.
- `code`: Language Code (String) - A short code representing the language (e.g., "fi" for Finnish, "en_gb" for English - Great Britain).
- `descrip`: Language Description (String) - The name of the language in English and the native language script.
- `flag`: Flag Image (String) - The filename of the flag image representing the language. The file format is PNG.
- `file`: Configuration File (String) - The name of the internal PHP translation file associated with the language translations.
- `default`: Default Status (Integer) - Indicates whether this language is the default (1 for default, 0 for non-default).
    

{
    "INFO": {
        "start": 0,
        "limit": 50,
        "count": 6,
        "total_count": 6
    },
    "OUTPUT": [
        {
            "id": "1",
            "code": "fi",
            "descrip": "Suomi (Finnish)",
            "flag": "fi.png",
            "file": "1.php",
            "default": 1
        },
        {
            "id": "2",
            "code": "en_gb",
            "descrip": "English (UK)",
            "flag": "gb.png",
            "file": "2.php",
            "default": 0
        },
        {
            "id": "5",
            "code": "fa_ir",
            "descrip": "فارسی (Farsi)",
            "flag": "ir.png",
            "file": "5.php",
            "default": 0
        },
        {
            "id": "11",
            "code": "es",
            "descrip": "Spanish (Español)",
            "flag": "es.png",
            "file": "11.php",
            "default": 0
        },
        {
            "id": "10",
            "code": "zh",
            "descrip": "中文 (Chinese)",
            "flag": "zh.png",
            "file": "10.php",
            "default": 0
        },
        {
            "id": "23",
            "code": "vi",
            "descrip": "Vietnamese",
            "flag": "vn.png",
            "file": "23.php",
            "default": 0
        }
    ]
}
    

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.