Download the PHP package car-api-team/carapi-php-sdk without Composer
On this page you can find all versions of the php package car-api-team/carapi-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download car-api-team/carapi-php-sdk
More information about car-api-team/carapi-php-sdk
Files in car-api-team/carapi-php-sdk
Package carapi-php-sdk
Short Description SDK for CarAPI. The developer friendly vehicle API.
License MIT
Informations about the package carapi-php-sdk
CarAPI PHP SDK
PHP ^7.4 and ^8.0 compatible SDK for the developer friendly vehicle API. Please review our documentation for a better understanding of how this SDK works:
Install
Install the SDK using composer:
If your project has a discoverable HTTP client then the SDK will use that automatically. If it does not, you will need to add one. You can read more about HTTP discovery here: https://github.com/php-http/discovery
Usage
Create the SDK instance using your token and secret. The following example assumes you've stored them in an .env
file, but you may load them in as you please.
You have now created an instance of the SDK.
Other Options
You may also set httpVersion
and encoding
. The HTTP version defaults to 1.1 and we recommend keeping it at that
version. Encoding is off by default, but GZIP is supported (note: you will need the zlib extension loaded). Example:
Authentication
The authenticate method will both return a JWT and store the JWT in the SDK internally. There is no persistent storage offered, so you will need to handle caching in your application. We'll provide a basic cache example using the file system, but we recommend using your frameworks caching library or something like symfony/cache or cake/cache.
Passing query parameters
Query parameters can be passed to api endpoints as key-value arrays.
Passing JSON searches
JSON search parameters can be passed to api endpoints as objects:
Pagination
Endpoints supporting pagination will return a collection property storing the pagination metadata and a data property
storing the actual results. Here is an example of paging through the /api/makes
endpoint:
Exceptions
The SDK will throw \CarApiSdk\CarApiException on errors. In some cases, this is just catching and rethrowing underlying HTTP Exceptions or JSON Exceptions. In most cases, this will capture errors from the API response and format them into a CarApiException.
Years
The years method returns an array of integers.
Get all years that Tesla sold cars:
Makes
Returns a collection.
Get all makes for 2020:
Models
Returns a collection.
Getting all 2020 Toyota models:
Trims
Returns a collection.
Getting all 2020 Ford F-150 trims:
Getting all 2020 Ford F-150 and F-250 trims:
Get all sedans by Toyota or Ford in 2020:
Or for a single trim an object is returned:
Vin
Returns an object
Loop through all trims returned by a vin lookup:
Bodies
Returns a collection.
Engines
Returns a collection.
Mileages
Returns a collection.
Interior Colors
Returns a collection.
Exterior Colors
Returns a collection.
CSV Datafeed
Returns the datafeed as a ResponseInterface. You will need handle extracting the file out in your application.
CSV Datafeed Last Update
Returns an object.
Vehicle Attributes
Returns an array of strings.
Account Requests
Returns an array of objects.
Account Requests Today
Returns an object:
All versions of carapi-php-sdk with dependencies
ext-json Version *
php-http/discovery Version ^1.19
psr/http-client-implementation Version ^1.0
psr/http-factory-implementation Version 1.0