===== mySmartGrid JSONP Interface ===== This page specifies the [[http://en.wikipedia.org/wiki/JSONP|JSONP]] interface that makes it possible for JavaScript clients from other Web domains to query sensor measurements from mySmartGrid. Below, we describe how the interface can be used to plot measurements on a chart using the [[http://dygraphs.com|Dygraphs library]]. You can see the example we are building [[https://www.mysmartgrid.de/sites/all/modules/logger/demo-chart.html|here.]] ==== How to Use ==== The first step is to load the Dygraphs libraries, as follows. Then, you need to declare the following // The response for the HTTP request performed by this // Click [[https://www.mysmartgrid.de/sites/all/modules/logger/demo-chart.html|here]] to see the result in a new page. ==== Security Considerations ==== The token grants you access to the sensor. Everyone who knows the token can also query your sensor values, so you must protect it. As you can see above, our API only works via HTTPS. In order to protect the token you should not expose it to others, i.e. by embedding the JavaScript from above in unencrypted HTML pages of your application. If you do **not** want to expose the token to the user, please go to the [[https://www.mysmartgrid.de/sensor/mylist|sensors page]], edit the sensor, and enter your website domain in the list of domains authorized to query the sensor. After that, mySmartGrid will authorize any query originated from a page loaded from your domain, so that you can omit the token argument from the HTTP request. Click [[https://www.mysmartgrid.de/sites/all/modules/logger/demo-chart-domain.html|here]] to see an example. At the moment, this feature is available only for some users. If you want to use it, please send an email to [[msg-support@itwm.fraunhofer.de]].