A Device API safari

Published: Sunday, May 4th 2014

There are many interesting things to be found in the Device API. This talk went on a journey to see what we could find worth playing with.

A 2 minute read 328 words

The Device API allows browsers to have more access to the underlying hardware on the host machine and allows it to appear more "native". Mostly this has been aimed at mobile devices and incorporates the very well known Orientation and Motion APIs. There are, however, a great many other Device APIs available, some of which are well supported and some that are only new.

This was a talk presented at Web Directions Code 2014 and explored numerous facets of the Device API, including:

  • Sensor APIs
  • Web NFC
  • Network APIs
  • Proximity
  • Battery Status
  • Vibration
  • Ambient light

The presentation is embedded below:

A Device API Safari - WDC 2014

The main aim of this talk was to have a large number of demos in the 20 minute presentation in order to show case what was possible. All the code for these demos is available in the repo.

The demos are embedded below if you'd like to play with them in more detail noting that support can be a bit hit and miss. Firefox is pretty much guaranteed.


Support: all mobile devices with a proximity sensor

Proximity detection


Support: All modern browsers except IE (any)

Battery level


Support: Most devices that have vibration motor in them

Application in HTML games:


Application in form error reporting:

Vibration form

Ambient light

Support: Firefox on desktop and most mobile devices

Application in contrast modification:

Ambient light for contrast modification

Application in silliness:

Ghosts appearing over video stream

Title image by Miwok

"A Device API safari" by ajfisher is licensed under a CC BY-NC-SA 4.0 International License.

Permanent source for attribution: https://www.ajfisher.me/2014/05/04/device-api-safari/.