Sky showed me Particle’s javascript library, and I thought I would post what I had to do to get it working.

Particle’s documentation can be found at:

My updated files are at:

  1. From the terminal, run:   npm install particle-api-js
  2. To allow you to use the library in the main script.js file, you must add this line to your index.html file: <script type="text/javascript" src="//"></script>. This line needs to go before you import the script.js file, so you should have your new line followed by the existing line that includes the script:
  3. Next, add the code to login at the top of your init function. Make sure to save your token to a global variable and don’t include the var Particle = require('particle-api-js');  line that the particle documentation says to include. Thus, the top of your init file should look something like:
  4. Now, you are set up and you can use the functions in the library. The only one I am using right now is the callFunction function. I call it whenever the default stool object is selected (check out the picker function in script.js). To call a function on your photon, you also need to register the function to the cloud within you photon code (see
    • My photon code:
    • The code to call the light function:


Let me know if I need to add anything to this post.