PHP code example of codebyray / carlistapi-php-sdk

1. Go to this page and download the library: Download codebyray/carlistapi-php-sdk 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/ */

    

codebyray / carlistapi-php-sdk example snippets


use CodebyRay\CarListApi\CarListApi;

$carList = new CarListApi(
    token: 'your-api-token'
);

use CodebyRay\CarListApi\Configuration;

$config = new Configuration(
    token: 'your-api-token',
    baseUrl: 'https://carlistapi.com/api',
    version: 'v1',
    timeout: 15,
    connectTimeout: 5,
    retryTimes: 2,
    retrySleepMs: 200,
);

$carList = new CarListApi($config);

$years = $carList
    ->automotive()
    ->years()
    ->data;

$makes = $carList
    ->automotive()
    ->makes(2026)
    ->data;

$models = $carList
    ->automotive()
    ->models(2026, 'Toyota')
    ->data;

$vehicle = $carList
    ->automotive()
    ->details($vehicleUuid)
    ->data;

$types = $carList
    ->powersports()
    ->types()
    ->data;

$models = $carList
    ->powersports()
    ->modelsByYearMakeAndType(
        'ATV / Utility',
        2026,
        'Can-Am'
    )
    ->data;

$vehicle = $carList
    ->vinDecoder()
    ->decode(
        '1HGCM82633A004352'
    )
    ->data;

$vehicle = $carList
    ->vinDecoder()
    ->decode(
        '1HGCM82633A004352',
        modelYear: 2003
    )
    ->data;

$response = $carList
    ->automotive()
    ->years();

$response->data;
$response->status;
$response->headers;

$response->header('X-RateLimit-Remaining');

try {

    $vehicle = $carList
        ->vinDecoder()
        ->decode($vin);

} catch (AuthenticationException $e) {

    //

} catch (RateLimitException $e) {

    //

} catch (ValidationException $e) {

    //

}

$config = new Configuration(
    token: 'your-api-token',
    version: 'v1',
);

$config = new Configuration(
    token: 'your-api-token',
    userAgent: 'my-application/2.0'
);
bash
composer 
text
codebyray/carlistapi-php-sdk/0.1.0