Skip to main content

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

Project description

FirmeAPI Python SDK

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

Requirements

  • Python 3.9+

Installation

pip install firmeapi

Quick Start

from firmeapi import FirmeApi

client = FirmeApi(api_key="your_api_key_here")

# Get company details
company = client.get_company("12345678")
print(company.denumire)

Sandbox Mode

Use sandbox mode to test your integration without consuming credits:

client = FirmeApi(api_key="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

get_company(cui: str) -> Company

Get detailed company information by CUI.

company = client.get_company("12345678")

print(company.denumire)              # Company name
print(company.stare)                 # Registration status
print(company.tva.platitor)          # VAT payer status
print(company.adresa_sediu_social)   # Headquarters address

get_bilant(cui: str) -> Bilant

Get company balance sheet data.

bilant = client.get_bilant("12345678")

for year in bilant.ani:
    print(f"{year.an}:")
    print(f"  Revenue: {year.detalii.I1} RON")
    print(f"  Profit: {year.detalii.I5} RON")
    print(f"  Employees: {year.detalii.I10}")

get_restante(cui: str) -> RestanteResponse

Get company ANAF debts.

restante = client.get_restante("12345678")

if restante.restante:
    print("Company has outstanding debts:")
    for debt in restante.restante:
        print(f"  {debt.tip_obligatie}: {debt.suma_restanta} RON")

get_mof(cui: str) -> MofResponse

Get company Monitorul Oficial publications.

mof = client.get_mof("12345678")

for publication in mof.rezultate:
    print(f"{publication.data}: {publication.titlu_publicatie}")

search_companies(**filters) -> SearchResponse

Search companies with filters.

results = client.search_companies(
    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,
)

print(f"Found {results.pagination.total} companies")

for company in results.items:
    print(f"{company.cui}: {company.denumire}")

get_administratori(cui: str)

admins = client.get_administratori("12345678")

get_puncte_lucru(**filters)

puncte = client.get_puncte_lucru(judet="CJ", caen="4711")

get_arr(cui: str)

arr = client.get_arr("36731044")

get_alternativ(cui: str)

alt = client.get_alternativ("51608780")

get_bpi_cui(cui: str, **options)

BPI insolvency publications by CUI. Premium credits required.

bpi = client.get_bpi_cui("16970632", page=1, include_document=True)

get_bpi_dosar(numar_dosar: str, **options)

bpi = client.get_bpi_dosar("103/89/2014")

get_bpi_search(query: str, **options)

bpi = client.get_bpi_search("lichidator")

get_bpi_by_number(numar_bpi: str, **options)

bpi = client.get_bpi_by_number("17605/2022")

get_dosare(**filters)

dosare = client.get_dosare(cui="53509960", categorie="Civil", is_finished=True)

get_free_company(cui: str) -> FreeCompany

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

company = client.get_free_company("12345678")
print(company.denumire)

Async Support

The SDK includes an async client for use with asyncio:

import asyncio
from firmeapi import AsyncFirmeApi

async def main():
    async with AsyncFirmeApi(api_key="your_api_key") as client:
        company = await client.get_company("12345678")
        print(company.denumire)

asyncio.run(main())

Error Handling

The SDK raises typed exceptions for different scenarios:

from firmeapi import (
    FirmeApi,
    AuthenticationError,
    NotFoundError,
    RateLimitError,
    InsufficientCreditsError,
    ValidationError,
    FirmeApiError,
)

try:
    company = client.get_company("12345678")
except NotFoundError:
    print("Company not found")
except AuthenticationError:
    print("Invalid API key")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after} seconds")
except InsufficientCreditsError as e:
    print(f"Not enough credits. Have: {e.available_credits}, need: {e.required_credits}")
except ValidationError as e:
    print(f"Invalid input: {e.message}")
except FirmeApiError as e:
    print(f"API error: {e.message}")

Configuration Options

client = FirmeApi(
    api_key="your_api_key",
    sandbox=False,                    # Enable sandbox mode (default: False)
    base_url="https://firmeapi.ro/api",  # Custom base URL
    timeout=30.0,                     # Request timeout in seconds (default: 30.0)
)

Context Manager

The client can be used as a context manager to ensure proper cleanup:

with FirmeApi(api_key="your_api_key") as client:
    company = client.get_company("12345678")
    print(company.denumire)

Type Hints

Full type hints are included for all methods and return values:

from firmeapi import Company, Bilant, SearchResponse

def process_company(company: Company) -> None:
    print(company.denumire)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

firmeapi-1.1.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

firmeapi-1.1.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file firmeapi-1.1.0.tar.gz.

File metadata

  • Download URL: firmeapi-1.1.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for firmeapi-1.1.0.tar.gz
Algorithm Hash digest
SHA256 2ac17b0bfb002320a74c134af3a9aaf6c38fbbfa6ecbecc71c0c8ec56fd87d2b
MD5 8d14317642955bc8a5bd46ff9662d848
BLAKE2b-256 b9cfcfb9fcba3634ecc441b7018e36413e9345e7a4c69581dd8e960207ee5f77

See more details on using hashes here.

File details

Details for the file firmeapi-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: firmeapi-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for firmeapi-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 132fb9a571df745640558f307eadf04046d498f8e0d623eddb5206b45ca19008
MD5 b58cedb4157cbb3cbdd5fadf950a9662
BLAKE2b-256 fd50b39799bfd201b8fcbc99b5de3a56094625217d4f5ac1cc9cbd05c302de8c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page