Skip to content

Mantix/kvk-api

 
 

Repository files navigation

KvK API Client (Dutch Chamber of Commerce)

Latest Version on Packagist Tests Total Downloads

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.

About

PHP package to retrieve data from the Dutch Chamber of Commerce (KvK)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%