Git Product home page Git Product logo

edmunds-sdk's Introduction

Edmunds SDK

Version License Downloads Scrutinizer

A simple but native implementation of a PHP SDK for the Edmunds API. Provides local object representations of remote data.

Installation

Install with Composer, obviously:

$ composer require coderstephen/edmunds-sdk

Usage

First, create an ApiClient instance of the type that corresponds to the desired Edmunds API, which connects to the Edmunds server:

$client = new Edmunds\SDK\VehicleApiClient('YOUR_API_KEY_HERE');

All available APIs extend from the ApiClient base class and are created in the same way. Pass in your Edmunds API key as the first argument. If you do not already have an API key, you will need to register with Edmunds first.

You can now access almost all of the Edmunds API with the client object. Currently, only the Vehicle API has object wrappers. To make a raw request to any endpoint, use the ApiClient::makeCall() method:

$response = $client->makeCall('/api/inventory/v2/inventories', [
    'zipcode' => '90404'
]);

foreach ($response->inventories as $inventory) {
    echo $inventory->vin;
}

See the Edmunds API documentation for details on what endpoints are available and their usage.

Vehicle API

A vehicle API client is provided to access Edmunds' extensive vehicle knowledge database. To use it, first create a VehicleApiClient object:

$client = new Edmunds\SDK\VehicleApiClient('YOUR_API_KEY_HERE');

The VehicleApiClient class extends ApiClient and provides several easy-to-use wrapper methods for accessing data objects. Below is a short example of some of the things you can do with the SDK:

use Edmunds\SDK;

$client = new SDK\VehicleApiClient('YOUR_API_KEY_HERE');

$makesIn2009 = $client->getMakes(null, 2009);
foreach ($makesIn2009->getModels() as $model) {
    $modelYear = $model->getYear(2009);
    printf('Model name: %s', $model->name);

    foreach ($modelYear->getStyles() as $style) {
        $firstPhoto = $style->getPhotos()[0];
        printf('Image URL: %s', $firstPhoto->getBestQualityUrl());
    }
}

Caching

The application that this library was originally created for required making thousands of API calls while processing artificial intelligence instructions. To lighten the heavy load, this library provides a really simple API call caching solution using the filesystem. To use the caching mechanism, pass an ApiCache object when creating an API client:

$cache = new Edmunds\SDK\ApiCache('/path/to/cache');
$client = new Edmunds\SDK\VehicleApiClient('YOUR_API_KEY_HERE', $cache);

Every time specific data about an entity is requested, the cache is checked first. If no cached data is found, an API call is made as normal, and the result is written to the cache for later.

License

Licensed under the Apache Public License 2.0. See the license file for details.

edmunds-sdk's People

Contributors

sagebind avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

edmunds-sdk's Issues

Cannot instantiate abstract class

Your docs and code don't match up from what I can tell. You have a constructor in an abstract class and you docs say to instantiate that abstract class. Something is missing.

I am happy to submit a PR unless it is me who is missing something.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.