The W3C Vehicle Information API aims to enable connectivity through in-vehicle infotainment systems and vehicle data access protocols. This API can also be leveraged by web applications running on mobile devices that access the data resources of a connected passenger vehicle.

This specification does not dictate or describe the access protocol or transport method used for the data connection. Data may come from numerous sources, e.g. OBD-II, MOST, CAN and LIN. Bluetooth, WiFi, or cloud connections are all possible.

The purpose of this specification is to promote an API that enables application development in a consistent manner across participating automotive manufacturers. It is recognized, however, that the mechanisms required for access or control of vehicle Properties may differ between automobile manufacturers, makes and models. Furthermore, different automobile manufacturers can expose different Properties that can be read or set by an application.

As a result of these constraints, this specification shall allow for automobile manufacturer-specific extensions or restrictions. Extensions are only permitted for interfaces that are not already described by this API, and must be implemented to conform within the format and guidelines existing in this specification. If a Property is restricted, the automobile manufacturer would omit the optional feature in their implementation (see the Availability Section).

The target platform supported by the specification is exclusively passenger vehicles. Use of this specification for non-passenger applications, e.g. transportation, heavy machinery, marine, airline infotainment, military, is not prohibited, but is not covered in the design or content of the API and therefore may be insufficient.

Initially, a typical use case of Vehicle Information might be the implementation of a 'Virtual Mechanic' application that provides vehicle status information such as tire pressure, engine oil level, washer fluid level or battery status. Future use case innovations in transportation, safety, navigation, smart energy grid and consumer infotainment and customization are all possible through this specification.

Web developers building interoperable applications based upon this API, will help empower a common web platform across consumer devices and passenger vehicles consistent with the Web of Things.

Deprecated - Work on this document has been discontinued and it should not be referenced or used as a basis for implementation. The W3C Automotive Working Group has taken a different direction.

Introduction

The Vehicle Information API provides operations to get access to the vehicle data (henceforth "properties") available from vehicle systems and also to change (write) a number of properties. Vehicle data types are available in the Vehicle Data specification.

An example of use is provided below:

        var vehicle = navigator.vehicle;

        vehicle.vehicleSpeed.get().then(function (vehicleSpeed) {
          console.log("Vehicle speed: " + vehicleSpeed.speed);
        },
        function (error) {
          console.log("There was an error");
        });

        var vehicleSpeedSub = vehicle.vehicleSpeed.subscribe(function (vehicleSpeed) {
          console.log("Vehicle speed changed to: " + vehicleSpeed.speed);
          vehicle.vehicleSpeed.unsubscribe(vehicleSpeedSub);
        });

        var zone = new Zone;

        var zones = vehicle.climateControl.zones;

        for (var i = 0, zone; zone = zones[i]; i++) {
          if (i.equals(zone.driver)) {
            var value = {};
            value["acStatus"] = true;
            vehicle.climateControl.set(value, zone.driver).then(function () {
              console.log("Successfully set acStatus");
            },
            function (error) {
              console.log("There was an error");
            });
          }
        }
  

This specification defines conformance criteria that apply to a single product: the user agent that implements the interfaces that it contains.

Implementations that use ECMAScript to implement the APIs defined in this specification MUST implement them in a manner consistent with the ECMAScript Bindings defined in the Web IDL specification [[!WEBIDL]], as this specification uses that specification and terminology.

Terminology

The Promise provide a convenient way to get access to the result of an operation.

Security and privacy considerations

It is expected that security of vehicle APIs described in this document is based on permissions dictated by:

No separate permission or access control model will be defined for vehicle APIs. Depending on a specific platform, the user agent used may have to provide tools to generate permissions for application descriptors as required by the OS. Android is an example under which such a descriptor (Android app manifest) has to be generated if the runtime maps its apps to OS-level apps.

Navigator Interface

readonly attribute Vehicle vehicle
The object that exposes the interface to vehicle information services.

Vehicle Interface

The Vehicle interface represents the initial entry point for getting access to the vehicle information services, i.e. Engine Speed and Tire Pressure.

Zone Interface

The Zone interface contains the constants that represent physical zones and logical zones

front
the front of the vehicle in the longitudinal-axis.
center
the center of the vehicle in the longitudinal-axis.
rear
the rear of the vehicle in the longitudinal-axis.
left
the left side of the vehicle in the horizontal-axis.
middle
the middle of the vehicle in the horizontal-axis.
right
the right side of the vehicle in the horizontal-axis.
top
the top layer of the vehicle in the vertical-axis.
central
the central layer of the vehicle in the vertical-axis.
bottom
the bottom layer of the vehicle in the vertical-axis.
attribute ZonePosition[] value
MUST return array of physical zones
readonly attribute Zone driver
MUST return physical zone for logical driver
boolean equals(Zone zone)
MUST return true if zone.value matches the contents of this.value. Ordering of elements within Zone.value does not matter.
boolean contains(Zone zone)
MUST return true if zone.value can be found within this.value

VehicleInterfaceCallback Callback

The VehicleInterfaceCallback

AvailableCallback Callback

The AvailableCallback

VehicleInterfaceError Interface

VehicleInterfaceError is used to identify the type of error encountered during an operation

permission_denied
Indicates that the user does not have permission to perform the operation. More details can be obtained through the Data Availability API.
invalid_operation
Indicates that the operation is not valid. This can be because it isn't supported or has invalid arguments
timeout
Operation timed out. Timeout length depends upon the implementation
invalid_zone
Indicates the zone argument is not valid
unknown
Indicates an error that is not known
readonly attribute VehicleError error
MUST return VehicleError
readonly attribute DOMString message
MUST return an error message describing the details of the error encountered. This is primarily intended for debugging and developers should not use it directly in their application user interface

VehicleInterface Interface

The VehicleInterface interface represents the base interface to get all vehicle properties.

Promise get(optional Zone zone)
MUST return the Promise. The "resolve" callback in the promise is used to pass the vehicle data type that corresponds to the specific VehicleInterface instance. For example, "vehicle.vehicleSpeed" corresponds to the "VehicleSpeed" data type. VehicleInterfaceError is passed to the 'reject' callback in the promise.
readonly attribute Zone[] zones
MUST return all zones supported for this type.
  vehicle.vehicleSpeed.get().then(resolve);

  function resolve(data) {
    // data is of type VehicleSpeed
    console.log("Speed: " + data.speed);
    console.log("Time Stamp: " + data.timestamp);
  }
  

VehicleConfigurationInterface Interface

The VehicleConfigurationInterface interface is to be used to provide access to static vehicle information that never changes, e.g. external dimensions, identification or transmission type.

VehicleSignalInterface Interface

The VehicleSignalInterface interface represents vehicle signals that, as a rule, and unlike vehicle configurations, can change values, either programmatically (necessitating support for set method) or due to external events and occurrences, as reflected by subscription management.

Promise set(object value, optional Zone zone)
MUST return Promise. The "resolve" callback indicates the set was successful. No data is passed to resolve. If there was an error, "reject" will be called with a VehicleInterfaceError object
unsigned short subscribe(VehicleInterfaceCallback callback, optional Zone zone, optional unsigned long period)
MUST return handle to subscription or 0 if error. If 'period' is specified, 'callback' MUST be invoked at most once per 'period' milliseconds.
void unsubscribe(unsigned short handle)
MUST return void. unsubscribes to value changes on this interface.
  var zone = Zone
  vehicle.door.set({"lock" : true}, zone.driver).then(resolve, reject);

  function resolve() {
    console.log("Successfully set");
  }

  function reject(errorData) {
    console.log("Error occurred during set: " + errorData.message + " code: " + errorData.error);
  }
  

Data Availability

The availability API allows for developers to determine what attributes are available or not and if not, why. It also allows for notifications when the availability changes.

available
data is available
not_supported
not supported by this vehicle
not_supported_yet
not supported at this time, but may become supported later.
not_supported_security_policy
not supported because of security policy
not_supported_business_policy
not supported because of business policy
not_supported_other
not supported for other reasons
Availability availableForRetrieval(DOMString attributeName)
MUST return whether this attribute is available for get() or not
readonly attribute boolean supported
MUST return true if this attribute is supported and available
short availabilityChangedListener( AvailableCallback callback )
MUST return handle for listener.
void removeAvailabilityChangedListener( short handle )
   var speedAvailability = vehicle.vehicleSpeed.availableForRetrieval("speed");
   
   if (speedAvailability === "available") {
     console.log("Vehicle speed available for use");
   }
   else {
     console.log("Vehicle speed unavailable: " + speedAvailability);
   }
   
Availability availableForSubscription(DOMString attributeName)
MUST return whether this attribute is available for subscribe() or not
Availability availableForSetting(DOMString attributeName)
MUST return whether this attribute is available for set() or not
   var speedSubscribable = vehicle.vehicleSpeed.availableForSubscription("speed") === "available";

   vehicle.vehicleSpeed.availabilityChangedListener(function (available) {
     speedSubscribable = available === "available";
     checkVehicleSpeed();
   });

   function checkVehicleSpeed() {
     if (speedSubscribable) {
       vehicle.vehicleSpeed.get().then(callback);
     }
   }
  

History

The History API provides a way for applications to access logged data from the vehicle. What data is available and how much is up to the implementation. This section is OPTIONAL.

readonly attribute any value
MUST return value. This is ANY Vehicle Data Type.
readonly attribute DOMTimeStamp timestamp
MUST return time in which 'value' was read by the system.
readonly attribute History? history
MUST return History interface if the platform supports the History API
Promise get(Date begin, Date end, optional Zone zone)
MUST return Promise. The "resolve" callback in the promise is used to pass an array of HistoryItems.
readonly attribute boolean isLogged
MUST return true if this attribute is logged
readonly attribute Date? from
MUST return Date in which logging started from. Returns null if isLogged is false.
readonly attribute Date? to
MUST return Date in which logging of this attribute ends. Returns null if isLogged is false.
   // check if there is data being logged for vehicleSpeed
   if (vehicle.vehicleSpeed.history.isLogged) {
     // get all vehicleSpeed since it was first logged
     vehicle.vehicleSpeed.history.get(
       vehicle.vehicleSpeed.history.from, 
       vehicle.vehicleSpeed.history.to
     ).then(function (data) {
       console.log(data.length);
     });
   }
   

Use-Cases

The primary purpose of this specification is to provide web developers the ability to access and set vehicle information through a simple common set of operations including get, set, subscribe, and unsubscribe. Thus normative use cases pertain to this access and do not cover higher application of business level use cases.

Get

Get a single value once from the vehicle.

Set

Set a single value once in the vehicle.

Subscribe

Subscribe to single value until unsubscribed.

Unsubscribe

Unsubscribe to single value.