Laravel wrapper for the Dutch open mobility data. Basic Vehicle Registration All non-sensitive data of the Dutch vehicle fleet.
Laravel application to get vehicle information from opendata.rdw.nl or overheid.io. \
This wrapper can be extended to be used in Filament:
Github: rdw-api-filament
Packagist: rdw-api-filament
Requires PHP 8.1 and Laravel 10 or higher
Install the package via composer:
composer require jdkweb/rdw-api
If needed you can publish the config
php artisan vendor:publish --provider="Jdkweb\RdwApi\RdwServiceProvider" --tag="config"
For changing options see: change API and Demo
If changes are needed you can publish the translation files
# published in: trans/vendor/jdkweb/rdw-api
php artisan vendor:publish --provider="Jdkweb\RdwApi\RdwServiceProvider" --tag="lang"
Translations available:
use Jdkweb\RdwApi\Controllers\RdwApiRequest;
...
$result = (object) RdwApiRequest::make()
->setLicenseplate('AB-895-P')
->fetch();
- Request to the active API (default: opendata.rdw.nl)
- All RDW endpoints are selected
- RdwApiResponse object is returned
use Jdkweb\RdwApi\Controllers\RdwApiRequest;
use Jdkweb\RdwApi\Enums\OutputFormat;
use Jdkweb\RdwApi\Enums\Endpoints;
...
$result = RdwApiRequest::make()
->setAPI(0)
->setLicenseplate('AB-895-P')
->setEndpoints(Endpoints::cases())
->setOutputformat(OutputFormat::JSON)
->setLanguage('en')
->fetch(true);
->setApi(int|string) // 0 | opendata | 1 | overheid
Overwrite the config settings
- 0 or 'opendata' for using the RDW API opendata.rdw.nl [default]
- 1 or 'overheidio' for using the overheid.io API
->setLicense('AB-895-P')
With or without hyphen-minus
use \Jdkweb\RdwApi\Enums\Endpoints;
...
->setEndpoints(array)
# examples:
// Call to all endpoints
->setEndpoints(Endpoints::cases())
// Specific selection
->setEndpoints([
Endpoints::VEHICLE,
Endpoints::FUEL
])
// Use enum names, case insensitive
->setEndpoints([
'vehicle',
'fuel'
])
Available endpoints (not case sensitive):
- Endpoints::VEHICLE | vehicle
- Endpoints::VEHICLE_CLASS |vehicle_class
- Endpoints::FUEL | fuel
- Endpoints::BODYWORK | bodywork
- Endpoints::BODYWORK_SPECIFIC | bodywork_specific
- Endpoints::AXLES | axles
- Endpoints::cases() [default]
use \Jdkweb\RdwApi\Enums\OutputFormat;
...
->setOuputformat(string|OutputFormat)
# examples
// Enum
->setOuputformat(OutputFormat::JSON)
// name, case insensitive
->setOuputformat('json')
- OutputFormat::ARRAY | array [default]
- OutputFormat::JSON | json
- OutputFormat::XML | xml
by using this method the response contains a formated output. see RdwApiResponse
->setLanguage(string)
Force output language, so form can be English and RDW response in Dutch.
Available:
- nl
- en
->fetch(?bool $return = null)
RdwApiResponse object will be returned
When boolean isset and true RdwApiRequest object will be returned
Response data form the RDW API request in $result:
Jdkweb\RdwApi\Controllers\RdwApiResponse {#2800 ▼
+response: array:2 [▶] // API response
+request: {#3036 ▶} // Request vars
+output: array:2 [▶] // Formated output when setOutputFormat is used
+status: true
}
$result->toArray()
$result->toJson()
$result->toXml(bool $pretty)
Boolean to make xml readable
$result->toObject()
Get specific values form response data, always use Dutch key for the value.
$result->quickSearch(string $keyname) // Keynames are Dutch
# examples:
// Brand: TOYOTA
$result->quickSearch('merk')
// Vehicle type: Personenauto
$result->quickSearch('voertuigsoort')
// Track width firste axle: 147
$result->quickSearch('1.spoorbreedte')
// First fuel description, hybrid have two
$set('brandstof_omschrijving', $result->quickSearch('1.brandstof_omschrijving'));
// Second axle legally permitted maximum axle load
$set('aslast', $result->quickSearch('2.wettelijk_toegestane_maximum_aslast'));
- Use dutch key for the value
- When more results:
Axles: axle_location_code for first and second:- 1.plaatscode_as
- 2.plaatscode_as
Request:
$result = RdwApiRequest::make()
->setLicenseplate('52BVL9')
->setEndpoints(Endpoints::cases())
->setOutputformat(OutputFormat::JSON)
->setLanguage('en')
->fetch(true);
the method setOutputformat creates a prepared output else output is empty
Response:
$result->output
# OR
$result->toJson()
$result is an RdwApiResponse object
Json output:
{
Vehicle: {
registration_number: "52BVL9",
vehicle_type: "Bus",
brand: "VDL",
trade_name: "CITEA LF-122/ ELECTRIC",
expiry_date_mot: "20250921",
date_of_registration: "20230721",
configuration: "bus",
number_of_seats: "37",
...
..
.
},
Fuel: {
registration_number: "52BVL9",
fuel_sequence_number: "1",
fuel_description: "Elektriciteit",
...
..
There is a demo available to test this wrapper
Two options to use the demo:
-
Add this value to .env
RDW_API_DEMO=1
-
Import the rwd-api config en set the value to 1 (Installation)
Demo: 0 = Off | 1 = On
rdw_api_demo => 1,
http://[domainname]/rdw-api/demo
Changing Default API\
- 0: opendata.rdw.nl
- 1: overheid.io
Use setApi method in request
->setApi(int $apiKey)
Or import the rwd-api config (Installation)
And set 'rdw_api_use' to the correct value
To use https://overheid.io a token is needed \
Place the token in the config: 'rdw_api_key'.
To use this wrapper in Filament install the filament extension
composer require jdkweb/rdw-api-filament
Github: jdkweb/rdw-api-filament
packagist: jdkweb/rdw-api-filament