PHP code example of finstat / client-api

1. Go to this page and download the library: Download finstat/client-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

finstat / client-api example snippets


// Basic API configuration
$apiUrl = 'https://www.finstat.sk/api/';    // URL for Slovak API (use 'https://cz.finstat.sk/api/' for Czech API)
$apiKey = 'YOUR_API_KEY';                  // Your unique API key
$privateKey = 'YOUR_PRIVATE_KEY';          // Your private key
$stationId = 'Your Station ID';            // Identifier for the station making the request
$stationName = 'Your Station Name';        // Name or description of the station
$timeout = 10;                             // Timeout in seconds for server response
$json = false;                             // Set to true if you want the API to return responses as JSON


nitialize the API client
$api = new FinStat\Api\FinstatApi($apiUrl, $apiKey, $privateKey, $stationId, $stationName, $timeout);

// Get basic company information
$ico = '35757442'; // Example company ICO
$basicInfo = $api->Request($ico, "basic", $json);

// Get detailed company information
$detailInfo = $api->Request($ico, "detail", $json);

// Get extended company information 
$extendedInfo = $api->Request($ico, "extended", $json);

// Get ultimate (most comprehensive) company information
$ultimateInfo = $api->Request($ico, "ultimate", $json);

// Search for companies by name
$autocompleteResults = $api->RequestAutoComplete('volkswagen', $json);

// Check API usage limits
$limits = $api->GetAPILimits();


nitialize the API client for Czech companies
$apiUrl = 'https://cz.finstat.sk/api/';
$api = new FinStatCZ\FinstatApi($apiUrl, $apiKey, $privateKey, $stationId, $stationName, $timeout);

// Get basic company information
$ico = '48207349'; // Example Czech company ICO
$basicInfo = $api->Request($ico, "basic", $json);

// Get detailed company information
$detailInfo = $api->Request($ico, "detail", $json);

// Get premium company information (financial data, bank accounts, turnover category)
$premiumInfo = $api->RequestPremiumCZ($ico, $json);

// Get elite company information: contacts, other CZ NACE activities, office count,
// vehicle fleet, ISIR insolvency proceedings, financial indicators (2 years)
$eliteInfo = $api->RequestEliteCZ($ico, $json);

// Get ultimate company information: everything from elite plus OR ČR / RŽP persons,
// statutory and procuration action, business subjects / trade licences, office list,
// vehicle fleet breakdowns, ISIR creditors and claim applications, credit scores and
// financial indicators (4 years), insolvency claims filed by the company as creditor
$ultimateInfo = $api->RequestUltimateCZ($ico, $json);

// Language of response texts (code list titles, NACE, ...): 'cs' or 'sk', passed per request
// as the last parameter of every Request* method; honoured by the Czech API only.
// Without it the server uses its default (Czech) or the Accept-Language header.
$eliteInfoSk = $api->RequestEliteCZ($ico, $json, 'sk');

// Search for companies by name
$autocompleteResults = $api->RequestAutoComplete('volkswagen', $json);


nitialize the monitoring API client (works with the Czech API URL too)
$api = new FinStat\Api\FinstatMonitoringApi($apiUrl, $apiKey, $privateKey, $stationId, $stationName, $timeout);

// Every call takes an optional monitoring category before $json; null uses the default one
$category = null;

// Add a company to monitoring by ICO
$ico = '35757442';
$success = $api->AddToMonitoring($ico, $category, $json);

// Add a date to monitoring
$date = "1.1.1991";
$success = $api->AddDateToMonitoring($date, $category, $json);

// Get list of monitored ICOs
$monitoredList = $api->MonitoringList($category, $json);

// Get list of monitored dates
$monitoredDateList = $api->MonitoringDateList($category, $json);

// Remove a company from monitoring
$success = $api->RemoveFromMonitoring($ico, $category, $json);

// Remove a date from monitoring
$success = $api->RemoveDateFromMonitoring($date, $category, $json);

// Get monitoring reports
$reports = $api->MonitoringReport($category, $json);
$dateReports = $api->MonitoringDateReport($category, $json);

// Bankruptcy and restructuring proceedings of the monitored companies and dates (Slovak API)
$proceedings = $api->MonitoringProceedings($json);
$dateProceedings = $api->MonitoringDateProceedings($json);

// Monitoring categories of the account (Czech API, or a Premium license on the Slovak one)
$categories = $api->MonitoringCategories($json);


 = new FinStat\Api\FinstatStatementApi($apiUrl, $apiKey, $privateKey, $stationId, $stationName, $timeout);

// Statements of a company, each with the templates it can be shown in
$statements = $api->RequestStatements($ico, $json);

// One statement in one template: Template2011v2, Template2014, Template2014micro, TemplateFinancial,
// TemplateROPO or TemplateNujPU (the last two are non-profit: Expenses and Revenue instead of IncomeStatement)
$statement = $api->RequestStatementDetail($ico, 2025, 'Template2014', $json);

// Row names of a template, in the given language (default 'sk')
$legend = $api->RequestStatementLegend('Template2014', 'sk', $json);


nitialize the daily diff API client
$api = new FinStat\Api\FinstatDailyDiffApi($apiUrl, $apiKey, $privateKey, $stationId, $stationName, $timeout);

// Get list of available daily diffs
$list = $api->RequestListOfDailyDiffs($json);

// Download a specific daily diff file
$file = "example_file.zip";
$data = $api->DownloadDailyDiffFile($file, $file);

// The same for statements, statements in the 2014 template and Ultimate data:
// FinstatDailyStatementDiffApi, FinstatDailyStatement2014DiffApi (each with RequestStatementLegend)
// and FinstatDailyUltimateDiffApi


 = new FinStat\Api\FinstatReportingApi($apiUrl, $apiKey, $privateKey, $stationId, $stationName, $timeout);

// Report topics, the reports of one topic, and one report file
$topics = $api->RequestTopics($json);
$reports = $api->RequestList($topics[0]->ID, $json);
$data = $api->DownloadReportFile($reports[0]->FileName, 'report.xlsx');


nitialize the bankruptcy and restructuring API client
$api = new FinStat\Api\FinstatBankruptcyRestructuringApi($apiUrl, $apiKey, $privateKey, $stationId, $stationName, $timeout);

// Get list of person bankruptcy proceedings ($dateOfBirth is a DateTime)
$list = $api->RequestPersonBankruptcyProceedings($name, $surname, new DateTime('1975-03-12'), $json);

// Get list of company bankruptcy and restructuring proceedings by ico
$list = $api->RequestCompanyBankruptcyRestructuring($ico, null, $json);

// Get list of company bankruptcy and restructuring proceedings by name
$list = $api->RequestCompanyBankruptcyRestructuring(null, $name, $json);


// This client is namespaced and loaded through composer's PSR-4 autoloader
nt
$api = new FinstatDistraintApi($apiUrl, $apiKey, $privateKey, $stationId, $stationName, $timeout);

// Live search — CHARGED. At least one of ico / companyName / fileReference /
// surname is ilResults wrapper holding a DistraintDetails list.
$token = $result->Distraints[0]->DetailToken;
$ids = array_map(function ($d) { return $d->DetailId; }, $result->Distraints);
$details = $api->RequestDistraintDetail($token, $ids, $json);
foreach ($details->DistraintDetails as $detail) {
    echo $detail->Code . ' ' . $detail->SumOutstanding . ' ' . $detail->Currency;
}

// Re-read what a previous live call already paid for — these three cost no credit
$stored     = $api->RequestDistraintResults(null, 'Mrkvicka', '12.03.1975', null, null, null, $json);
$byToken    = $api->RequestDistraintResultsByToken($token, $json);
$oneDetail  = $api->RequestDistraintStoredDetail($result->Distraints[0]->StoredDetailId, $json);

use FinStat\Client\Exceptions\FinstatException;
use FinStat\Client\Exceptions\LimitReachedException;
use FinStat\Client\Exceptions\NotFoundException;
use FinStat\Client\Exceptions\RegisterUnavailableException;

try {
    $response = $api->Request($ico, "basic", $json);
} catch (NotFoundException $e) {
    // HTTP 404 - no company for this ICO
} catch (LimitReachedException $e) {
    // HTTP 402 - daily/monthly allowance spent, or not enough credit
    $daily = $e->getDailyCurrent() . '/' . $e->getDailyMax();
} catch (RegisterUnavailableException $e) {
    // HTTP 502 - upstream register down; no credit was charged, safe to retry
} catch (FinstatException $e) {
    // Every exception above extends FinstatException, so this catches the rest
    $code    = $e->getCode();        // the HTTP status code
    $message = $e->getMessage();     // the server response body, when it sent one
    $url     = $e->getRequestUrl();  // request context, set on every exception
    $param   = $e->getRequestParameter();
}

$limits = $api->GetAPILimits();

// Example output format:
// [
//   'daily' => ['current' => 10, 'max' => 100],
//   'monthly' => ['current' => 50, 'max' => 1000]
// ]