Weather API Tutorial

The new Weather API Tutorial shows how to use the OpenWeather API to get current condition and forecast data using the (usually free) Open Weather API, use Webhooks to extract only the data you are interested in, and send this to your Particle device.

It also has an API request and response viewer like in the Cloud API Tutorial so you can better understand the requests and responses.

In order to select which fields you want to send to your device, you just click the checkboxes. For example: temperature, pressure, and humidity. I also selected 3 days of day temp and night temp.

Then it automatically creates your webhook for you!

  "url": "",
  "noDefaults": true,
  "rejectUnauthorized": true,
  "event": "GetWeatherData",
  "requestType": "GET",
  "responseTopic": "{{PARTICLE_DEVICE_ID}}/{{PARTICLE_EVENT_NAME}}",
  "query": {
    "lat": "42.999999",
    "lon": "-75.999999",
    "exclude": "minutely,hourly,alerts",
    "units": "metric",
    "appid": "xxx"
  "responseTemplate": "{\"temp\":{{current.temp}},\"pres\":{{current.pressure}},\"hum\":{{current.humidity}},\"daily\":[{\"day\":{{}},\"night\":{{daily.0.temp.night}} },{\"day\":{{}},\"night\":{{daily.1.temp.night}} },{\"day\":{{}},\"night\":{{daily.2.temp.night}} }] }"

It also generates sample code for parsing the abbreviated response data on your device using the built-in JSON parser:

void subscriptionHandler(const char *event, const char *data) {
    JSONValue outerObj = JSONValue::parseCopy(data);
    JSONObjectIterator iter(outerObj);
    while( {
        if ( == "temp") {
  "temp=%lf", iter.value().toDouble());
        if ( == "pres") {
  "pressure=%lf", iter.value().toDouble());
        if ( == "hum") {
  "humidity=%lf", iter.value().toDouble());
        if ( == "daily") {
            JSONArrayIterator iter2(iter.value());
            for(size_t ii = 0;; ii++) {
      "daily array index %u", ii);
                JSONObjectIterator iter3(iter2.value());
                while( {
                    if ( == "day") {
              "", iter3.value().toDouble());
                    if ( == "night") {
              "temp.night=%lf", iter3.value().toDouble());