API - Vehicles_v2

We now offer an API for you to use in other applications to check whether a vehicle was stolen or not.

The API will the check the main database of entries added directly into this website, as well as the BOLO section, where we obtain information from social media.

With V2, you will now need to have an active user account on this system as well as an API key which will be used for authentication for each API request.

Please take the necessary steps now to ensure that your system can access the API:

1) Go to https://stolenvehicles.co.za/users/register and create a user account. You will receive an email with an activation link.

2) Activate your user account by clicking on the link in the email.

3) Now that your user account is active, go to https://stolenvehicles.co.za/users/my_profile and select "Yes" next to option "API Access Required".

4) Click on "Edit Profile". The page will reload after 2 seconds and you will then see your API key.

You just need to call the URL as shown in the examples below with your API key as the first parameter and the search term as the second parameter.

The search term must either be the: VIN Number OR Registration/License Plate Number OR Engine Number. A minimum of 4 characters are required

Base URL

https://stolenvehicles.co.za/api/vehicles_v2/

GET Example

GET https://stolenvehicles.co.za/api/vehicles_v2/f50ad5327b62c6f8h9a4v61339f02d13/CA529663

POST Example

POST https://stolenvehicles.co.za/api/vehicles_v2/

                                        
{
    "api_key": "f50ad5327b62c6f8h9a4v61339f02d13/CA529663",
    "search_term": "CA529663"
}
                                        
                    
API Response
                                        
{
    "result": "Stolen",
    "type": "Motorcycle",
    "stolen_date": "2018-03-14",
    "vin_number": "WB10404JXWZC43519",
    "reg_number": "CA529663",
    "engine_number": "112EB299870",
    "make": "BMW",
    "model": "R1100GS",
    "year": "1994",
    "color": "Red",
    "province": "Gauteng",
    "last_known_location": "Magaliesburg",
    "description": "Adventure bike with aluminum top box",
    "case_number": "CAS46\/3\/2018",
    "police_station": "Randburg",
    "datadot_id": "",
    "source_system": "https://stolenvehicles.co.za",
    "link": "https://stolenvehicles.co.za\/vehicles\/view\/86"
}
                                        
                    

Code Examples

                            
$ch = curl_init();

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
));
curl_setopt($ch, CURLOPT_URL, "https://stolenvehicles.co.za/api/vehicles_v2/f50ad5327b62c6f8h9a4v61339f02d13/CA529663");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$result = curl_exec($ch);
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if (curl_error($ch)) {
    echo 'Error:' . curl_error($ch) . ".\nHTTP Status: " . $http_status;
}

curl_close($ch);

if ($http_status == 200) {
    //A JSON object will be returned if the vehicle details were found.
    //We then decode it and get an array.
    $vehicle_data = json_decode($result, true);
    
    //Check the result value...
    $result = $vehicle_data['result'];
    
    if($result == "Stolen") {
        //We can now extract all the fields, or specific fields from the array.
        $vin_number = $vehicle_data['vin_number'];
        $stolen_date = $vehicle_data['stolen_date'];

        //Save the data to a database or echo it out to screen.
        echo "This vehicle with VIN:$vin_number was stolen on $stolen_date.";
    } else {
        echo "No data found.";
    }
} elseif ($http_status == 401) {
    echo "Unauthorized access. - " . $result;
} elseif ($http_status == 404) {
        echo "Resource not found. - " . $result;
} elseif ($http_status == 403) {
        echo "Forbidden. - " . $result;
}
                            
                    
                            
var reg_number = "CA529663";

$.ajax({
    type: 'GET',
    url: 'https://stolenvehicles.co.za/api/vehicles_v2/f50ad5327b62c6f8h9a4v61339f02d13/' + reg_number,
    dataType: 'jsonp',
    success: function (data) {
        console.log(data);

        if (data.result == "Stolen") {
            alert("Vehicle with registration number " + reg_number + " was stolen on " + data.stolen_date + ".");
        } else {
            alert("No data found...");
        }
    }
});
                            
                    
                            
var api_key = "f50ad5327b62c6f8h9a4v61339f02d13";
var reg_number = "CA529663";

function send() {
    var json_data = {
        api_key: api_key,
        search_term: reg_number
    }

    $.ajax({
        url: 'https://stolenvehicles.co.za/api/vehicles_v2/',
        type: 'post',
        dataType: 'json',
        contentType: 'application/json',
        success: function (data) {
            console.log(data);

            if (data.result == "Stolen") {
                alert("Vehicle with registration number " + reg_number + " was stolen on " + data.stolen_date + ".");
            } else {
                alert("No data found...");
            }
        },
        data: JSON.stringify(json_data)
    });
}