Hue JavaScript Example

This example uses the Hue API v.1 and the JS fetch command to make HTTP calls to a Hue bridge.

NOTE: This will not work when the page is served from a network outside your home. To see it work, download this example and open the index.html page in a browser from your computer.

See the HTML source code here

When you first connect your app to a hue hub, the hub issues you an app username. It's a long string of text that you'll use for subsequent requests.
To create a new user on a hub, you need to give the hue a devicetype. If you don't know what to put, use your own name, as it's easier to keep track that way.
  1. enter devicetype:
  2. press the button on the hub
  3. then within 30 seconds, press this button:
  4. If you succeed, the results will appear below, and also in the username field.

The following functions require the hub IP address and a valid app username.

To get the whole system status as a long JSON object:
To change an individual light:




Messages from the hub will appear here