定制 firmeapi/firmeapi-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

firmeapi/firmeapi-php

最新稳定版本:v1.1.0

Composer 安装命令:

composer require firmeapi/firmeapi-php

包简介

Official PHP SDK for FirmeAPI.ro - Romanian company data API

README 文档

README

Official PHP SDK for FirmeAPI.ro - Romanian company data API.

Requirements

  • PHP 8.1 or higher
  • cURL extension
  • JSON extension

Installation

composer require firmeapi/firmeapi-php

Quick Start

use FirmeApi\FirmeApi;

$client = new FirmeApi('your_api_key_here');

// Get company details
$company = $client->getCompany('12345678');
echo $company['denumire'];

Sandbox Mode

Use sandbox mode to test your integration without consuming credits:

$client = new FirmeApi('your_api_key_here', ['sandbox' => true]);

// Test CUIs available in sandbox:
// 00000001 - Active company with all data
// 00000002 - Inactive/deleted company
// 00000003 - Company with multiple VAT periods
// 00000004 - Company with ANAF debts
// 00000005 - Company with MOF publications
// 99999999 - Returns 404 (for testing errors)

API Methods

getCompany(string $cui): array

Get detailed company information by CUI.

$company = $client->getCompany('12345678');

echo $company['denumire'];              // Company name
echo $company['stare'];                 // Registration status
echo $company['tva']['platitor'];       // VAT payer status
print_r($company['adresa_sediu_social']); // Headquarters address

getBilant(string $cui): array

Get company balance sheet data.

$bilant = $client->getBilant('12345678');

foreach ($bilant['ani'] as $year) {
    echo "{$year['an']}:\n";
    echo "  Revenue: {$year['detalii']['I1']} RON\n";
    echo "  Profit: {$year['detalii']['I5']} RON\n";
    echo "  Employees: {$year['detalii']['I10']}\n";
}

getRestante(string $cui): array

Get company ANAF debts.

$restante = $client->getRestante('12345678');

if (!empty($restante['restante'])) {
    echo "Company has outstanding debts:\n";
    foreach ($restante['restante'] as $debt) {
        echo "  {$debt['tip_obligatie']}: {$debt['suma_restanta']} RON\n";
    }
}

getMof(string $cui): array

Get company Monitorul Oficial publications.

$mof = $client->getMof('12345678');

foreach ($mof['rezultate'] as $publication) {
    echo "{$publication['data']}: {$publication['titlu_publicatie']}\n";
}

searchCompanies(array $filters = []): array

Search companies with filters.

$results = $client->searchCompanies([
    'judet' => 'B',           // County code
    'caen' => '6201',         // CAEN code
    'tva' => true,            // VAT payer only
    'telefon' => true,        // Has phone number
    'data_start' => '2024-01-01',
    'data_end' => '2024-12-31',
    'page' => 1,
]);

echo "Found {$results['pagination']['total']} companies\n";

foreach ($results['items'] as $company) {
    echo "{$company['cui']}: {$company['denumire']}\n";
}

getAdministratori(string $cui): array

$admins = $client->getAdministratori('12345678');

getPuncteLucru(array $filters = []): array

$puncte = $client->getPuncteLucru(['judet' => 'CJ', 'caen' => '4711']);

getArr(string $cui): array

$arr = $client->getArr('36731044');

getAlternativ(string $cui): array

$alt = $client->getAlternativ('51608780');

getBpiCui(string $cui, array $options = []): array

BPI insolvency publications by CUI. Premium credits required.

$bpi = $client->getBpiCui('16970632', ['page' => 1, 'include_document' => true]);

getBpiDosar(string $numarDosar, array $options = []): array

$bpi = $client->getBpiDosar('103/89/2014');

getBpiSearch(string $query, array $options = []): array

$bpi = $client->getBpiSearch('lichidator');

getBpiByNumber(string $numarBpi, array $options = []): array

$bpi = $client->getBpiByNumber('17605/2022');

getDosare(array $filters = []): array

$dosare = $client->getDosare(['cui' => '53509960', 'categorie' => 'Civil']);

getFreeCompany(string $cui): array

Get basic company info using the free API (no API key required, rate limited).

$company = $client->getFreeCompany('12345678');
echo $company['denumire'];

Error Handling

The SDK throws typed exceptions for different scenarios:

use FirmeApi\FirmeApi;
use FirmeApi\Exceptions\AuthenticationException;
use FirmeApi\Exceptions\NotFoundException;
use FirmeApi\Exceptions\RateLimitException;
use FirmeApi\Exceptions\InsufficientCreditsException;
use FirmeApi\Exceptions\ValidationException;
use FirmeApi\Exceptions\FirmeApiException;

try {
    $company = $client->getCompany('12345678');
} catch (NotFoundException $e) {
    echo "Company not found\n";
} catch (AuthenticationException $e) {
    echo "Invalid API key\n";
} catch (RateLimitException $e) {
    echo "Rate limited. Retry after {$e->getRetryAfter()} seconds\n";
} catch (InsufficientCreditsException $e) {
    echo "Not enough credits. Have: {$e->getAvailableCredits()}, need: {$e->getRequiredCredits()}\n";
} catch (ValidationException $e) {
    echo "Invalid input: {$e->getMessage()}\n";
} catch (FirmeApiException $e) {
    echo "API error: {$e->getMessage()}\n";
}

Configuration Options

$client = new FirmeApi('your_api_key', [
    'sandbox' => false,                    // Enable sandbox mode (default: false)
    'baseUrl' => 'https://firmeapi.ro/api', // Custom base URL
    'timeout' => 30,                        // Request timeout in seconds (default: 30)
]);

Laravel Integration

You can easily integrate with Laravel using a service provider:

// config/services.php
return [
    'firmeapi' => [
        'key' => env('FIRMEAPI_KEY'),
        'sandbox' => env('FIRMEAPI_SANDBOX', false),
    ],
];

// app/Providers/AppServiceProvider.php
use FirmeApi\FirmeApi;

public function register(): void
{
    $this->app->singleton(FirmeApi::class, function () {
        return new FirmeApi(
            config('services.firmeapi.key'),
            ['sandbox' => config('services.firmeapi.sandbox')]
        );
    });
}

// Usage in controllers
public function show(FirmeApi $firmeApi, string $cui)
{
    $company = $firmeApi->getCompany($cui);
    return response()->json($company);
}

License

MIT

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固