PHP code example of jdkweb / rdw-api

1. Go to this page and download the library: Download jdkweb/rdw-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jdkweb / rdw-api example snippets


use Jdkweb\RdwApi\Controllers\RdwApiRequest;
...
$result = (object) RdwApiRequest::make()
    ->setLicenseplate('AB-895-P')
    ->fetch();

use Jdkweb\RdwApi\Controllers\RdwApiRequest;
use Jdkweb\RdwApi\Enums\OutputFormats;
use Jdkweb\RdwApi\Enums\Endpoints;
...
$result = RdwApiRequest::make()
    ->setAPI(0)
    ->setLicenseplate('AB-895-P')
    ->setEndpoints(Endpoints::cases())
    ->setOutputformat(OutputFormats::JSON)
    ->setLanguage('en')
    ->fetch(true);

->setApi(int|string) // 0 | opendata | 1 | overheid    

->setLicense('AB-895-P')

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'
    ])

use \Jdkweb\RdwApi\Enums\OutputFormats;
...
->setOuputformat(string|OutputFormat)

# examples
    
    // Enum
    ->setOuputformat(OutputFormats::JSON)
    
    // name, case insensitive
    ->setOuputformat('json')

->setLanguage(string)

->fetch(?bool $return = null) 

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)

$result->toObject()

$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'));

$result = RdwApiRequest::make()
    ->setLicenseplate('52BVL9')
    ->setEndpoints(Endpoints::cases())
    ->setOutputformat(OutputFormat::JSON)
    ->setLanguage('en')
    ->fetch(true);

$result->output
# OR
$result->toJson()

    RDW_API_DEMO=1
   

    rdw_api_demo => 1,
   

->setApi(int $apiKey)
bash
php artisan vendor:publish --provider="Jdkweb\RdwApi\RdwServiceProvider" --tag="config"
bash
# published in: trans/vendor/jdkweb/rdw-api
php artisan vendor:publish --provider="Jdkweb\RdwApi\RdwServiceProvider" --tag="lang"