daadkracht-marketing-bv / dutch-chamber-of-commerce-api
Package to interact with the Dutch Chamber of Commerce API (KVK)
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^7.8
- illuminate/contracts: ^10.0|^11.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- larastan/larastan: ^2.0.1
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.8
- orchestra/testbench: ^8.8|^9.0
- pestphp/pest: ^2.20
- pestphp/pest-plugin-arch: ^2.5
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2024-05-15 11:47:17 UTC
README
This package provides a simple way to interact with the Dutch Chamber of Commerce API (KVK).
Requirements
You need to have a valid API key from the Dutch Chamber of Commerce. You can request one here.
Features
- Search for companies by name, address, postal code, city, and more
- Fetch the base profile of a company by its Chamber of Commerce number
- Fetch the branches of a company by its Chamber of Commerce number
- Fetch the profile of a branch by its branch number
- Requests are chainable
Installation
You can install the package via composer:
composer require daadkracht-marketing-bv/dutch-chamber-of-commerce-api
You can publish the config file with:
php artisan vendor:publish --tag="dutch-chamber-of-commerce-api-config"
These are the contents of the published config file:
return [ 'api_key' => env('DUTCH_CHAMBER_OF_COMMERCE_API_KEY'), ];
Usage
Search API
Initiate a basic search request in the following way
$response = DutchChamberOfCommerceApi::searchRequest() ->place('Drachten') ->streetName('De Opgang') ->fetch();
The acceptable chained search methods are:
cocNumber(string $cocNumber)
- The Chamber of Commerce number of the companyrsin(string $rsin)
- The RSIN of the companybranchNumber(string $branchNumber)
- The branch number of the companyname(string $name)
- The name of the companyplace(string $place)
- The place of the companystreetName(string $streetName)
- The street name of the companyhouseNumber(int $houseNumber)
- The house number of the companyhouseLetter(string $houseLetter)
- The house letter of the companypostalCode(string $postalCode)
- The postal code of the companyplace(string $place)
- The place of the companypoBoxNumber(int $poBoxNumber)
- The PO box number of the companytype(array|string $type)
- The type of the company (e.g. "Hoofdvestiging")includeInactiveRegistrations(bool $includeInactiveRegistrations)
- Whether to include inactive registrations
You can also specify the number of results to return and the page number to return, in the following way:
$response = DutchChamberOfCommerceApi::searchRequest() ->place('Leeuwarden') ->streetName('Sophialaan') ->resultsPerPage(10) ->page(2) ->fetch();
The fetch
method will return a SearchResponse
object with a results
collection
The items in the results
collection are SearchResponseResultItem
objects, which have the following properties:
cocNumber
- The Chamber of Commerce number of the companyrsin
- The RSIN of the companybranchNumber
- The branch number of the companyname
- The name of the companyaddresses
- The addresses of the company (a collection ofDomesticAddress
and/orForeignAddress
) objects. These differ from the genericAddress
object in that they have different properties.type
- The type of the company/branchactive
- Whether the company/branch is active
Branches API
You can fetch the branches of a company by its Chamber of Commerce number in the following way:
$response = DutchChamberOfCommerceApi::baseProfileBranchesRequest() ->cocNumber('12345678') ->fetch();
The fetch
method will return a BaseProfileBranchesResponse
object.
You can query the branches on this response object in the following way:
$branches = $response->branches;
This will return a collection of Branch
objects.
You can filter these with e.g.:
$branches = $response->branches->where('isMainBranch', true);
A branch object will also allow you to call the createFullBranchProfileRequest
method to fetch a full profile of the branch. (see below for more information on the full branch profile API)
This can be chained in the following way:
$fullBranchProfile = DutchChamberOfCommerceApi::baseProfileBranchesRequest() ->cocNumber('63546167') ->fetch() ->branches->firstWhere('isMainBranch', true) ->createFullBranchProfileRequest() ->fetch();
A branch object has the following properties:
branchNumber
- The branch number of the branchfirstTradeName
- The first trade name of the branchisMainBranch
- Whether the branch is the main branch of the companyisShieldedAddress
- Whether the address of the branch is shieldedisCommercialBranch
- Whether the branch is a commercial branchfullAddress
- The full address of the branch
(Full) Branch Profile API
You can fetch the profile of a branch by its branch number in the following way:
$response = DutchChamberOfCommerceApi::branchProfileRequest() ->branchNumber('12345678') ->fetch();
If you also want to request geographical information, you can do so in the following way:
$response = DutchChamberOfCommerceApi::branchProfileRequest() ->branchNumber('12345678') ->withGeo(true) ->fetch();
The fetch
method will return a BranchProfileResponse
object.
A branch profile response has the following properties:
branchNumber
- The branch number of the branchcocNumber
- The Chamber of Commerce number of the companyrsin
- The RSIN of the companynonMailingIndicator
- The non-mailing indicators of the companyformalDateOfRecord
- The formal date of record of the company (when the record was changed)materialRegistration
- The material registration of the companystatutoryName
- The statutory name of the companyfirstTradeName
- The first trade name of the companyisMainBranch
- Whether the branch is the main branch of the companyisCommercialBranch
- Whether the branch is a commercial branchfulltimeEmployees
- The number of full-time employees of the branchparttimeEmployees
- The number of part-time employees of the branchtotalEmployees
- The total number of employees of the branchtradeNames
- The trade names of the branch (a collection ofTradeName
objects)addresses
- The addresses of the branch (a collection ofAddress
objects)websites
- The websites of the branch (a collection of URLs)sbiActivities
- The SBI activities of the branch (a collection ofSbiActivity
objects)
Base Profile API
You can fetch the base profile of a company by its Chamber of Commerce number in the following way:
$response = DutchChamberOfCommerceApi::baseProfileRequest() ->cocNumber('12345678') ->fetch();
If you also want to request geographical information, you can do so in the following way:
$response = DutchChamberOfCommerceApi::baseProfileRequest() ->cocNumber('12345678') ->withGeo(true) ->fetch();
The fetch
method will return a BaseProfileResponse
object with the following properties:
cocNumber
- The Chamber of Commerce number of the companynonMailingIndicator
- The non-mailing indicators of the companyname
- The name of the companyformalDateOfRecord
- The formal date of record of the company (when the record was changed)totalNumberOfEmployees
- The total number of employees of the companystatutoryName
- The statutory name of the companytradeNames
- The trade names of the company (a collection ofTradeName
objects)sbiActivities
- The SBI activities of the company (a collection ofSbiActivity
objects)
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.