tor2r/laravel-brreg-api

Fetch data from Brønnøysundregisteret.

Fund package maintenance!
Tor2r

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/tor2r/laravel-brreg-api

v1.0.1 2026-02-11 22:49 UTC

This package is auto-updated.

Last update: 2026-02-11 22:50:40 UTC


README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

A Laravel package for fetching basic data from Brønnøysundregisteret (the Norwegian Register of Business Enterprises). Supports both Enhetsregisteret and Frivillighetsregisteret.

Requirements

  • PHP 8.2 or higher
  • Laravel 11 or 12

Installation

You can install the package via composer:

composer require tor2r/laravel-brreg-api

You can publish the config file with:

php artisan vendor:publish --tag="brreg-api-config"

This is the contents of the published config file:

return [
    'base_url' => env('BRREG_API_BASE_URL', 'https://data.brreg.no'),
    'results_per_page' => env('BRREG_API_RESULTS_PER_PAGE', 100),
];

Usage

Enhetsregisteret (Business Registry)

use Tor2r\BrregAPi\Facades\BrregAPi;

// Fetch a single entity by organisation number
$entity = BrregAPi::getByOrgnr('987654321');

// Search by name
$results = BrregAPi::searchByName('Sesam');

// Limit the number of results
$results = BrregAPi::searchByName('Sesam', 10);

Frivillighetsregisteret (Voluntary Organisations Registry)

// Fetch a single voluntary organisation
$org = BrregAPi::voluntary()->getByOrgnr('987654321');

// Search voluntary organisations by name
$results = BrregAPi::voluntary()->searchByName('Frivillig');

Response Format

Single entity (getByOrgnr) returns a flat array with the entity data:

$entity = BrregAPi::getByOrgnr('925183873');

// [
//     'organisasjonsnummer' => '925183873',
//     'navn' => 'FAGFOKUS AS',
//     'organisasjonsform' => [...],
//     'forretningsadresse' => [...],
//     'antallAnsatte' => 7,
//     ...
// ]

Search methods (searchByName) return a structured response with data and meta:

$results = BrregAPi::searchByName('Fagfokus');

// [
//     'data' => [
//         [
//             'organisasjonsnummer' => '925183873',
//             'navn' => 'FAGFOKUS AS',
//             'antallAnsatte' => 7,
//             ...
//         ],
//     ],
//     'meta' => [
//         'per_page' => 100,
//         'total' => 1,
//         'total_pages' => 1,
//         'current_page' => 0,
//     ],
// ]

Internal API fields (_links, respons_klasse) are automatically stripped from responses.

Error Handling

The package throws Tor2r\BrregAPi\Exceptions\BrregApiException when something goes wrong:

use Tor2r\BrregAPi\Exceptions\BrregApiException;

try {
    $entity = BrregAPi::getByOrgnr('000000000');
} catch (BrregApiException $e) {
    // "No entity found with organisation number: 000000000"
    echo $e->getMessage();
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.