The package exposes the same fluent API through the BirRegon facade and the
BirRegonService container binding.
Search by NIP, REGON, or KRS:
use cieplik206\BirRegon\Data\CompanyData;
use cieplik206\BirRegon\Facades\BirRegon;
/** @var CompanyData $byNip */
$byNip = BirRegon::forNip('1234567890')->get();
$byRegon = BirRegon::forRegon('123456789')->get();
$byKrs = BirRegon::forKrs('0000123456')->get();
get() and search() are aliases:
$company = BirRegon::forNip('1234567890')->search();
Each search returns a CompanyData object:
$company->name;
$company->nip;
$company->regon;
$company->city;
$payload = $company->toArray();
$json = $company->toJson();
Type-hint BirRegonService when an explicit dependency is preferable to a
facade:
use cieplik206\BirRegon\BirRegonService;
use cieplik206\BirRegon\Data\CompanyData;
class FindCompany
{
public function __construct(
private BirRegonService $birRegon,
) {}
public function handle(string $nip): CompanyData
{
return $this->birRegon->forNip($nip)->get();
}
}
The service and facade resolve the same singleton from Laravel’s service container.
Select the dedicated sandbox service before building the request:
$company = BirRegon::sandbox()
->forNip('7740001454')
->get();
The sandbox service uses BIR_SANDBOX_API_KEY and keeps a session independent
from production. Reuse the returned service for related sandbox calls.