PullMonkey Blog

17 Jan

VIN API - PHP and XML Parsing


Thanks go to Michael for sharing his hard work with the rest of you VIN API and PHP developers :)
I hope this helps -



22 Responses to “VIN API - PHP and XML Parsing”

  1. By Page Smith on Mar 21, 2011 | Reply

    Hi Guys, this is fantastic stuff! Could you please show where in the above PHP implementation I would indicate the “complete = true;” option? Would I need to remove the array for this to work?

    Sorry I just saw examples of how to return all variables in Ruby and Windows Server implementations, but didn’t catch a PHP way to return ALL xml variables available.

    Also, one other question, I did get a working test going and tried multiple very popular manufacturers and models of cars but basic things like the “Transmission:” type never came back for me, even though they were listed in the above code example. Do you find this common or perhaps was there a code issue?

    Thanks in advance! If I can get this running well I will have someone willing to continually buy VINs from you haha.

  2. By charlie on Mar 21, 2011 | Reply

    1) add ?complete=true, like this:
    curl_setopt ($curl, CURLOPT_URL, ‘http://vinapi.skizmo.com/vins/’.$vin.’.xml?complete=true’);

    2) Interesting, I’d like to take a look, please send me an email with the VINs that did not return transmission data - support at mrquotey dot com

    Great :)

  3. By Robin Daugherty on Mar 28, 2011 | Reply

    Page, to go through all of the items returned in the XML, you’ll need to parse it. There are a few libraries to do this. I use SimpleXMLElement:

    $e = new SimpleXMLElement($this->xml);

    foreach($e->children() as $item) {
    $name = $item->getName();
    $value = (string)$item;
    }

  4. By Page Smith on Mar 28, 2011 | Reply

    Thank you both, that is a great help in understanding this a bit more!

  5. By vlad on Oct 9, 2011 | Reply

    I want to use vinapi on my site. Can anyone help me?

  6. By charlie on Oct 9, 2011 | Reply

    Sure - are you having a specific problem? What language are you working with? Are you a developer?

  7. By vlad on Oct 9, 2011 | Reply

    I want to use php. I’m a not a developer. I dont know how can I start this script. I want to buy vin packages and use on my site to decode vins for check auto parts compatibility.

  8. By charlie on Oct 9, 2011 | Reply

    You can find a php example here - http://vinapi.skizmo.com/examples

  9. By Ron Eskinder on Jan 21, 2012 | Reply

    Hi,

    i need to get an API key to be able to use the VIN decoder, what do i have to do to get one
    Thanks

  10. By charlie on Jan 21, 2012 | Reply

    Hey Ron -

    Starting from http://vinapi.skizmo.com, there is a signup link in the upper-right of the page.
    This link will take you here - http://vinapi.skizmo.com/signup
    After signing up, you’ll get your API key and 20 free VINs with which to test.
    After that, you can take a look at the packages and prices of what we offer - http://vinapi.skizmo.com/packages_and_pricing

    If you have any questions, just let me know,

    - Charlie

  11. By just J on Jun 13, 2012 | Reply

    Hey,

    I just coded this up in C# and it isn’t returning a “complete” decode. Below is the code so you can clearly see I have complete set to true and all I get is the basic info. Anything that I should do different?

    private string ReturnXML()
    {
    string vin = “VIN_GOES_HERE”;

    WebClient wc = new WebClient();
    wc.Headers.Add(”X-VinApiKey”, “THIS_IS_MY_KEY”);

    Stream data = wc.OpenRead(”http://vinapi.skizmo.com/vins/” + vin + “.xml?complete=true”);
    StreamReader reader = new StreamReader(data);
    string s = reader.ReadToEnd();

    return s;
    }

    I’d like to purchase your service if I can get this working.

  12. By charlie on Jun 13, 2012 | Reply

    just J -

    Let me see if I can help - can you give me some VINs that you’d like complete datasets for?
    I’ll see if it is your code, our code or our data.

    It’s not saying much, but I’m getting complete datasets when requested via API, see below:

    # getting the basic set:
    >> VinApi.get(”1HGCM82633A004352″)
    => {”model”=>”ACCORD EX”, “body_style”=>”Coupe”, “country”=>”USA”, “world_region”=>”North America”, “vin”=>”1HGCM82633A004352″, “engine_type”=>”FWD”, “transmission”=>”Automatic”, “make”=>”Honda”, “year”=>”2003″}

    # getting the complete set
    >> VinApi.get(”1HGCM82633A004352″, :complete => true)
    => {”front_split_bench_seat”=>”N/A”, “telescopic_steering_column”=>”Std.”, “powertrain_warranty_distance”=>”36,000 mile”, “leather_seat”=>”Std.”, “automatic_load_leveling”=>”N/A”, “load_bearing_exterior_rack”=>”N/A”, “front_spring_type”=>”Coil”, “steel_wheels”=>”N/A”, “maximum_gvwr”=>”No data lbs”, “rear_wiper”=>”N/A”, “leather_steering_wheel”=>”Std.”, “front_brake_type”=>”Disc”, “rear_brake_type”=>”Disc”, “vehicle_anti_theft”=>”Std.”, “overall_length”=>”187.60 in.”, “pickup_truck_bed_liner”=>”N/A”, “front_side_airbag_with_head_protection”=>”N/A”, “second_row_side_airbag_with_head_protection”=>”N/A”, “cd_changer”=>”Std.”, “second_row_folding_seat”=>”Std.”, “am_fm_radio”=>”Std.”, “locking_pickup_truck_tailgate”=>”N/A”, “fog_lights”=>”Opt.”, “maximum_towing”=>”1000 lbs”, “msrp”=>”$25,900 USD”, “genuine_wood_trim”=>”N/A”, “powertrain_warranty_duration”=>”36 month”, “cruise_control”=>”Std.”, “front_power_lumbar_support”=>”N/A”, “power_sunroof”=>”Std.”, “towing_preparation_package”=>”N/A”, “city_mpg”=>”21 miles/gallon”, “pickup_truck_cargo_box_light”=>”N/A”, “front_legroom”=>”43.10 in.”, “first_aid_kit”=>”N/A”, “mpg_hwy”=>”30 miles/gallon”, “sliding_rear_pickup_truck_window”=>”N/A”, “cargo_area_tiedowns”=>”Std.”, “wheelbase”=>”105.10 in.”, “electronic_parking_aid”=>”N/A”, “second_row_side_airbag”=>”N/A”, “rear_spring_type”=>”Coil”, “driveline”=>”FWD”, “driver_multi_adjustable_power_seat”=>”Std.”, “dvd_player”=>”Opt.”, “tow_hitch_receiver”=>”N/A”, “track_rear”=>”61.20 in.”, “deep_tinted_glass”=>”N/A”, “maximum_payload”=>”No data lbs”, “model_year”=>”2003″, “abs_brakes”=>”Std.”, “standard_gvwr”=>”No data lbs”, “power_adjustable_exterior_mirror”=>”Std.”, “keyless_entry”=>”Std.”, “standard_seating”=>”5″, “heated_exterior_mirror”=>”N/A”, “cassette_player”=>”Opt.”, “rust_duration”=>”60 month”, “tilt_steering_column”=>”Std.”, “limited_slip_differential”=>”N/A”, “transmission”=>”5-Speed Automatic Overdrive”, “depth”=>”No data in.”, “highway_mpg”=>”30 miles/gallon”, “cargo_net”=>”Std.”, “dealer_invoice”=>”$23,305 USD”, “passenger_volume”=>”88.00 cu.ft.”, “engine_type”=>”3.0L V6 SOHC 24V”, “rear_shoulder_room”=>”55.40 in.”, “warranty_duration”=>”36 month”, “rain_sensing_wipers”=>”N/A”, “driver_airbag”=>”Std.”, “interval_wipers”=>”Std.”, “tank”=>”17.10 gallon”, “remote_ignition”=>”N/A”, “wind_deflector_for_convertibles”=>”N/A”, “second_row_multi_adjustable_power_seat”=>”N/A”, “warranty_distance”=>”36,000 mile”, “optional_seating”=>”No data”, “front_headroom”=>”37.50 in.”, “exterior_color”=>”Taffeta White”, “destination_charge”=>”No data USD”, “voice_activated_telephone”=>”Opt.”, “air_conditioning”=>”Std.”, “interior_trim”=>”Ivory Leather Interior”, “chrome_wheels”=>”Opt.”, “child_safety_door_locks”=>”N/A”, “second_row_sound_controls”=>”N/A”, “front_suspension”=>”Ind”, “electronic_brake_assistance”=>”N/A”, “cd_player”=>”Std.”, “overall_height”=>”55.70 in.”, “front_heated_seat”=>”Std.”, “track_front”=>”61.10 in.”, “year”=>”2003″, “splash_guards”=>”Opt.”, “locking_differential”=>”N/A”, “cargo_length”=>”No data in.”, “navigation_aid”=>”N/A”, “anti_brake_system”=>”4-Wheel ABS”, “model”=>”Accord”, “adjustable_foot_pedals”=>”N/A”, “front_power_memory_seat”=>”N/A”, “front_hip_room”=>”54.20 in.”, “run_flat_tires”=>”N/A”, “passenger_multi_adjustable_power_seat”=>”Std.”, “power_windows”=>”Std.”, “second_row_removable_seat”=>”N/A”, “alloy_wheels”=>”Std.”, “glass_rear_window_on_convertible”=>”N/A”, “rear_spoiler”=>”Opt.”, “rust_distance”=>”Unlimited mile”, “heated_steering_wheel”=>”N/A”, “tire_pressure_monitor”=>”N/A”, “electrochromic_exterior_rearview_mirror”=>”N/A”, “cargo_volume”=>”12.80 cu.ft.”, “separate_driver_front_passenger_climate_controls”=>”Std.”, “rear_hip_room”=>”46.10 in.”, “removable_top”=>”N/A”, “subwoofer”=>”N/A”, “cargo_area_cover”=>”N/A”, “ground_clearance”=>”No data in.”, “rear_suspension”=>”Ind”, “power_trunk_lid”=>”N/A”, “running_boards”=>”N/A”, “third_row_removable_seat”=>”N/A”, “manual_sunroof”=>”Std.”, “side_head_curtain_airbag”=>”Std.”, “trip_computer”=>”N/A”, “rear_headroom”=>”36.10 in.”, “standard_payload”=>”No data lbs”, “overall_width”=>”71.30 in.”, “steering_wheel_mounted_controls”=>”Std.”, “turning_diameter”=>”35.40 in.”, “body_style”=>”COUPE 2-DR”, “front_shoulder_room”=>”56.10 in.”, “second_row_heated_seat”=>”N/A”, “telematics_system”=>”N/A”, “vehicle_stability_control_system”=>”N/A”, “width_at_wheelwell”=>”No data in.”, “tachometer”=>”Std.”, “make”=>”Honda”, “electrochromic_interior_rearview_mirror”=>”Opt.”, “daytime_running_lights”=>”N/A”, “automatic_headlights”=>”Std.”, “manufactured_in”=>”UNITED STATES”, “tires”=>”205/60R16″, “front_air_dam”=>”Std.”, “power_door_locks”=>”Std.”, “power_sliding_side_van_door”=>”N/A”, “standard_towing”=>”1000 lbs”, “front_side_airbag”=>”Std.”, “curb_weight”=>”No data lbs”, “trim_level”=>”EX V6 coupe AT”, “rear_legroom”=>”31.90 in.”, “width_at_wall”=>”No data in.”, “steering_type”=>”R&P”, “mpg_city”=>”21 miles/gallon”, “traction_control”=>”Std.”, “high_intensity_discharge_headlights”=>”N/A”, “rear_window_defogger”=>”Std.”, “skid_plate”=>”N/A”, “full_size_spare_tire”=>”N/A”, “passenger_airbag”=>”Std.”, “tilt_steering”=>”Std.”, “trunk_anti_trap_device”=>”Std.”, “four_wd_awd”=>”N/A”, “front_cooled_seat”=>”N/A”}

    - Charlie

  13. By just J on Jun 14, 2012 | Reply

    Hey,

    Thanks for the quick reply. I tried the same VIN you have and it was a full dataset, so I know it isn’t my code. I tried the below VINs from my database, which are current vehicles on the market today from multiple dealerships and all of them returned a short dataset.

    1FTRW07L43KD01241
    1FMFU17L94LB60432
    1FTRW12W65KC97784
    JM1NC25F160114359
    JTDBT4K38A4067275
    3VWRW3AL0AM011110
    JA3AJ26E35U053323

    Not sure what the issue is but anyway I can help you to resolve it, just let me know.

    Regards,
    Jacob

  14. By charlie on Jun 15, 2012 | Reply

    Thanks for the test VINs Jacob - I’ll see what we can figure out and get back to you asap.

  15. By charlie on Jun 15, 2012 | Reply

    Jacob - let’s see how these changes hold up - let me know how it goes.

  16. By just J on Jun 15, 2012 | Reply

    Hey,

    I tried a few of them and they worked. I then went to my database and pulled out a small list to check and only the last one I tried worked. Now, I get the “out of credits” error. I don’t want to buy credits until I know your service will work for me. Below is the list of the new list I tried.

    2G1WC5EM2B1192127
    1D4RD4GGXBC698496
    2G1WG5EK2B1210242
    1G6DW6ED3B0160975
    3GNBABFW5BS547555
    JHMGE8H48AS000967
    5FNRL5H47BB015649
    1FTRW07L43KD01241 - worked.

  17. By charlie on Jun 15, 2012 | Reply

    Hey Jacob - I credited you with 200 VIN requests. So please verify and make sure I have the right Jacob :) You can do the equivalent of VinApi.get(”account_information”) to check.
    Strangely enough, those VINs all work for me (again, not saying much). I’ve added a ton more loggers and we’ll get to the bottom of this. It has to do with our caching of data sets, for which I’ve fixed a few areas of overlap.
    Initially, everything was just the “basic” data set and we have some stubborn VINs in there that we’ve been washing out.
    Thanks again for the help.

  18. By just J on Jun 15, 2012 | Reply

    I tried the 10 and 1 came back with a full dataset, 1 was invalid check-sum (guessing the dealer input the vin wrong) and the rest were all short datasets.

    I want to get at least 50% working, that way I can charge dealers per full dataset only and still come out with a little profit.

    Now this is weird… I just ran the same 10 VINs again and 6 of 10 (minus one for invalid VIN) came back with a full dataset. Not sure if you are updating one database with another on the fly or using JOIN but something isn’t working right on your end.

  19. By just J on Jun 18, 2012 | Reply

    Hey,

    Not sure what you changed, but thanks! I ran 5 and they all came back with full datasets, ran 5 more and they all came back good. I then tried 10 and 100% full datasets. I logged into my account to see how many remaining credits I had and noticed you bumped it up (thanks for that) so I ran 75 VINs at once and guess what? That’s right, 100% full datasets! I’m very pleased and now writing a class to parse the info that I need from it. Just made my day! It was pretty quick, too. I ran each VIN single threaded and it was finished in under 2 minutes.

    Regards,
    Jacob

  20. By charlie on Jun 19, 2012 | Reply

    Hey Jacob - worked a bit over the weekend, found a couple places that were of issue and refactored them. Thanks for the update and thanks again for the help troubleshooting.

  21. By thas on Aug 18, 2012 | Reply

    how to get api key ?

  22. By charlie on Aug 19, 2012 | Reply

    thas -

    You get an api key from vinapi.skizmo.com here - http://vinapi.skizmo.com/signup. When you sign up, you’ll get an api key good for 20 VIN decodings. After that, you pick from the packages available here - http://vinapi.skizmo.com/packages_and_pricing.

Sorry, comments for this entry are closed at this time.