Inventory developer API

Introduction


AutoChoice24.com provides to developers an easy-to-use API (application programming interface) to integrate the dealer account inventory to your own inventory.
The advantage of it is, you can manage your entire inventory through our system and, at the same time, host your own website containing your inventory. It is specially convenient for SEO practices.

Using the API


We made sure to keep the API as simple as we could without compromising security. There are two (2) requirements (or information) you need to send with your request:

Getting your API key


All dealer accounts have access to an API key without the need of going to a registration process. To get your API key simply login into your dealer dashboard and click Dealer API Settings.
Follow the instructions on the screen to generate your key.

Making API requests


There are several technologies you can use to accomplish the same task so, we will keep things on the realm of PHP and JavaScript (jQuery). The API accepts only POST type request so, make sure to keep that in mind when writing your code.
The API will return a JSON object containing your inventory or, an error string if the request fails. We strongly recommend you (developer) to save the JSON data to your server so you can make sure to always have data available to display on the website in which you are integrating the API.

PHP request (with cURL)


            <?php
                $_API_KEY = 'xxxxxxxxxx';
                $_ACC_EMAIL = 'xxx@xxxxxxxxxx.xxx';

                if( !$curl = @curl_init() ){
                    die('NG ' . __LINE__);
                }

                @curl_setopt( $curl, CURLOPT_URL, 'https://autochoice24.com/api/validate/' );
                @curl_setopt( $curl, CURLOPT_POST, 1 );
                @curl_setopt( $curl, CURLOPT_POSTFIELDS, "api_key=" . $_API_KEY . '&pw=' . $_ACC_EMAIL );
                @curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );

                // assign returned data to var.
                $res = @curl_exec($curl);

                if( curl_errno($curl) ){
                    //@curl_close($curl);
                    echo 'NG ' . __LINE__ . ': ' . curl_errno($curl);
                    die();
                }

                @curl_close($curl);

                // check if JSON or error string is returned.
                $json = json_encode($res, true); // encode to array.

                if( json_last_error() == JSON_ERROR_NONE ){
                    // it's an object. save the json data so you can maintain a backup in case subsequent
                    // requests fail.
                } else {
                    // you got an error message. handle error here...
                }
            ?>
            

JavaScript (jQuery Framework)


The same can be achieved using jQuery POST request:
                <script type="text/javascript">
                    $.post(
                        'https://autochoice24.com/api/validate/',
                        {
                            'api_key' : 'xxxxxxxxxxxxxxxxx',
                            'pw' : 'xxxxxxxx@xxxxxxxxxx.xxx'
                        },
                        function( data ){
                            try {
                                var json = JSON.parse(data);

                                console.log(json); // see your JS console...
                            } catch( error ){
                                // an error has been returned. handle it here...
                            }
                        }
                    ).error(function(er){
                        alert('Error: ' + er);
                    });
                </script>
            

JSON Output format


Once the request is done, you will receive a string in JSON object format. Each index contains one (1) entry on your inventory. If your inventory contains no vehicles, and empty object will be returned.
                [0]: Object(
                        class: "Sport Utility Vehicles"
                        creation: "2015-01-30 14:57:50"
                        currency_code: "USD"
                        currency_symbol: "$"
                        description: "...."
                        doors: "4"
                        driven_wheels: "FWD"
                        engine_compression: "10.3"
                        engine_configuration: "inline"
                        engine_cylinder: "6"
                        engine_displacement: "4160"
                        engine_horse_power: "285"
                        engine_size: "4.2"
                        engine_torque: "276"
                        engine_valves: "24"
                        exterior_color: "Brown"
                        featured: "0"
                        fuel: "gasoline"
                        interior_color: "Black"
                        make: "Chevrolet"
                        manufacture_code: "XXXX"
                        mileage: "125000"
                        mileage_type: "mile"
                        model: "TrailBlazer"
                        mpg_city: "14"
                        mpg_highway: "20"
                        price: "27615.00"
                        src: "https://autochoice24.com/image/vehicle/1/B8TYFS8CRK9.png"
                        state: "U"
                        status: "A"
                        stock_number: "XXXXXX"
                        style: "4dr SUV"
                        transmission_speed: "4"
                        transmission_type: "automatic"
                        trim: "Fleet"
                        type: "suv"
                        vehicle_id: "XXXXXXXXXX"
                        vendor: "xxxxxxxxxxxx"
                        vin: "XXXXXXXXXXXXXXXXX"
                        year: "2008"
                    )
                [1] Object ...
            
Note: Status: A = available, S = Sold, R = reserved. State: U = used and N = new.
Don't hesitate in contacting our developers through our contact form for further questions or inquires.