mantix / kvk-api
KvK API client (Dutch Chamber of Commerce API)
Fund package maintenance!
mantix
Requires
- php: ^7.4|^8.0|^8.1|^8.2|^8.3
- guzzlehttp/guzzle: ^7.0
- illuminate/support: ^8.0 || ^9.0 || ^10.0 || ^11.0
- psr/http-message: ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- mockery/mockery: ^1.6
- phpstan/phpstan: ^1.12
- phpunit/phpunit: ^9.6
- spatie/ray: ^1.28
README
A robust PHP package for interacting with the Dutch Chamber of Commerce (KvK) API. This package is a fork of vormkracht10/kvk-api
with additional features and improvements.
Features
- Search companies by name, KvK number, RSIN, or establishment number
- Fetch detailed company profiles
- Built-in caching to minimize API calls
- Rate limiting to respect API guidelines
- Comprehensive error handling
- PSR-7 compliant
Data Available
For each company, you can retrieve:
- KvK number
- Establishment number
- Trade name(s)
- Address(es) including:
- Type
- Full address
- Street
- House number
- Postal code
- City
- Country
- Website(s)
- Basic profile information (new)
Installation
Install the package via Composer:
composer require mantix/kvk-api
Required dependencies:
composer require illuminate/support composer require psr/http-message composer require guzzlehttp/guzzle
Getting Started
First, obtain your API key from the KvK Developer Portal.
use Mantix\KvkApi\ClientFactory; $apiKey = '<YOUR_KVK_API_KEY>'; $kvk = ClientFactory::create($apiKey);
Basic Company Search
// Search by company name $companies = $kvk->search('Mantix'); // Search with pagination $kvk->setPage(1) ->setResultsPerPage(10); $companies = $kvk->search('Mantix');
Specific Searches
// By KvK number $companies = $kvk->searchByKvkNumber('12345678'); // By RSIN $companies = $kvk->searchByRsin('123456789'); // By establishment number $companies = $kvk->searchByVestigingsnummer('000012345678');
Get Company Profile
// Fetch detailed company profile $profile = $kvk->getBaseProfile('12345678');
Advanced Usage
// Search with additional parameters $companies = $kvk->search('Mantix', [ 'pagina' => 1, 'resultatenPerPagina' => 10, // Add any other API parameters ]); // Using SSL certificate $rootCertificate = '<PATH_TO_SSL_CERT>'; $kvk = ClientFactory::create($apiKey, $rootCertificate);
Error Handling
The package includes comprehensive error handling:
use Mantix\KvkApi\Exceptions\KvkApiException; try { $companies = $kvk->search('Mantix'); } catch (KvkApiException $e) { // Handle API-specific errors echo $e->getMessage(); } catch (\Exception $e) { // Handle general errors echo $e->getMessage(); }
Testing
composer test
Documentation
Contributing
Contributions are welcome! Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.