codewithdennis / chamber-of-commerce
A PHP wrapper tailored for simplifying and enhancing interactions with the Chamber of Commerce API from The Netherlands.
Requires
- php: ^8.1
- illuminate/contracts: ^10.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.8
README
This Kamer van Koophandel (Chamber of Commerce) API wrapper enables seamless interaction with the Kamer van Koophandel (Chamber of Commerce) API, enabling you to access information about businesses and organizations registered in the Netherlands. For comprehensive details, please visit the official Kamer van Koophandel website.
Installation
You can install the package via composer:
composer require codewithdennis/chamber-of-commerce
You can publish the config file with:
php artisan vendor:publish --tag="chamber-of-commerce-config"
This is the contents of the published config file:
return [ 'key' => env('COC_API_KEY'), 'test_key' => env('COC_API_TEST_KEY'), 'test_enabled' => env('COC_API_TEST_ENABLED', false) ];
How to Use
Add your API key to the .env
file
COC_API_KEY=<YOUR_API_KEY> COC_API_TEST_KEY="l7xx1f2691f2520d487b902f4e0b57a0b197"
Create an instance of the ChamberOfCommerce class to start making API requests:
use CodeWithDennis\ChamberOfCommerce\ChamberOfCommerce; $chamberOfCommerce = new ChamberOfCommerce();
Use the search function
Search by KvK number
$chamberOfCommerce->number('12345678');
Search by business name number
$chamberOfCommerce->name('IKEA');
Search by RSIN number
$chamberOfCommerce->rsin('123456789');
Include inactive companies in the search results.
$chamberOfCommerce->withInactiveCompanies(true);
Search by branche number
$chamberOfCommerce->branchNumber('B1234');
Search by street name
$chamberOfCommerce->streetName('Hullenbergweg');
Search by postal code (In combination with house number)
$chamberOfCommerce->postalCode('1234 AB');
Search by house number (requires postal code)
$chamberOfCommerce->houseNumber(2);
Search by house number addition
$chamberOfCommerce->houseNumberAddition('A');
Search by location (city, place)
$chamberOfCommerce->location('Amsterdam');
Search by business type
// Options: hoofdvestiging (main office), nevenvestiging (branch office), rechtspersoon (legal entity) $chamberOfCommerce->type('hoofdvestiging');
Set the page number for pagination (you can use this to iterate through pages)
$chamberOfCommerce->page(1);
Set the number of results per page.
$chamberOfCommerce->pagination(10);
After chaining your methods, you can initiate the API request by invoking the "search" function like so:
$response = $chamberOfCommerce ->name('IKEA') ->location('Amsterdam') ->pagination(5) ->search();
Basic profiles
To fetch basic profiles for a particular KvK (Chamber of Commerce) number, you can use the following code:
$response = $chamberOfCommerce ->withGeo() ->number(33143768) ->profiles();
Test environment
To utilize the testing environment, simply enable it in your .env
file:
COC_API_TEST_ENABLED=true
Ensure that you include the following key in your .env
file:
COC_API_TEST_KEY="l7xx1f2691f2520d487b902f4e0b57a0b197"
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.