Weather API Developer's Guide

Seven Day Weather Forecast Example

This section provides an example of a simple seven day weather forecast request.

Note: The code examples use the placeholder text {YOUR_APP_CODE} and {YOUR_APP_ID} to indicate places where you should substitute your own unique app_id and app_code values. For more information about these authentication credentials, see Acquiring Credentials.

User Story

The user wants to obtain a daily weather forecast for seven days for Chicago, Illinois, USA.

Request Summary

Resource: report – note that resource representation is specified via extensions .xml or .json
Parameters: product – indicates what kind of report the query requests; in this example, the query uses the parameter value forecast_7days_simple to request a daily forecast for the next seven days
  latitude – indicates the latitude of the location for which the query requests a weather forecast
  longitude – indicates the longitude of the location for which the query requests a weather forecast

Request

The code block below demonstrates the complete request, specifying that the response data are to be delivered in JSON.


https://weather.cit.api.here.com/weather/1.0/report.json
?app_id={YOUR_APP_ID}
&app_code={YOUR_APP_CODE}
&product=forecast_7days_simple
&latitude=41.83
&longitude=-87.68

Here is the same request indicating that the response data are to be delivered in XML.


https://weather.cit.api.here.com/weather/1.0/report.xml
?app_id={YOUR_APP_ID}
&app_code={YOUR_APP_CODE}
&product=forecast_7days_simple
&latitude=41.83
&longitude=-87.68

Response

The response to the request contains:

  • daily forecasts for Chicago, Illinois

The example response in JSON format is as follows:


{
  "dailyForecasts": {
  "forecastLocation": {
    "forecast": [
    {
      "daylight": "D",
      "description": "Drizzle. Overcast. Cool.",
      "skyInfo": "18",
      "skyDescription": "Overcast",
      "temperatureDesc": "Cool",
      "comfort": "9.21",
      "highTemperature": "12.00",
      "lowTemperature": "7.80",
      "humidity": "94",
      "dewPoint": "10.43",
      "precipitationProbability": "28",
      "precipitationDesc": "Drizzle",
      "rainFall": "0.00",
      "snowFall": "*",
      "airInfo": "32",
      "airDescription": "Damp",
      "windSpeed": "18.26",
      "windDirection": "163",
      "windDesc": "South",
      "windDescShort": "S",
      "uvIndex": "0",
      "uvDesc": "Minimal",
      "barometerPressure": "1007.17",
      "icon": "18",
      "iconName": "sprinkles",
      "iconLink": "https://weather.cit.api.here.com/static/weather/icon/27.png",
      "dayOfWeek": "4",
      "weekday": "Wednesday",
      "utcTime": "2013-12-04T00:00:00.00-06:00"
    },
    {
      "daylight": "D",
      "description": "Sprinkles late. High level clouds. Cool.",
      "skyInfo": "12",
      "skyDescription": "High level clouds",
      "temperatureDesc": "Cool",
      "comfort": "-6.32",
      "highTemperature": "8.90",
      "lowTemperature": "-3.40",
      "humidity": "55",
      "dewPoint": "-8.74",
      "precipitationProbability": "18",
      "precipitationDesc": "Sprinkles late",
      "rainFall": "*",
      "snowFall": "*",
      "airInfo": "*",
      "airDescription": "",
      "windSpeed": "21.96",
      "windDirection": "276",
      "windDesc": "West",
      "windDescShort": "W",
      "uvIndex": "0",
      "uvDesc": "Minimal",
      "barometerPressure": "1012.06",
      "icon": "18",
      "iconName": "sprinkles",
      "iconLink": "https://weather.cit.api.here.com/static/weather/icon/27.png",
      "dayOfWeek": "5",
      "weekday": "Thursday",
      "utcTime": "2013-12-05T00:00:00.00-06:00"
    },
    {
      ---remaining observations removed to shorten document 
    }
    ],
    "country": "United States",
    "state": "Illinois",
    "city": "Chicago",
    "latitude": 41.83,
    "longitude": -87.68,
    "distance": 0,
    "timezone": -6
  }
  },
  "feedCreation": "2013-12-04T09:44:13.574",
  "metric": true
}

The example response in XML format is as follows:


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  <WeatherReport>
    <dailyForecasts>
      <forecastLocation timezone="-6" distance="0.00" longitude="-87.68" latitude="41.83" city="Chicago" state="Illinois" country="United States">
        <forecast utcTime="2013-12-04T00:00:00.00-06:00" weekday="Wednesday" dayOfWeek="4">
          <daylight>D</daylight>
          <description>Drizzle. Overcast. Cool.</description>
          <skyInfo>18</skyInfo>
          <skyDescription>Overcast</skyDescription>
          <temperatureDesc>Cool</temperatureDesc>
          <comfort>9.21</comfort>
          <highTemperature>12.00</highTemperature>
          <lowTemperature>7.80</lowTemperature>
          <humidity>94</humidity>
          <dewPoint>10.43</dewPoint>
          <precipitationProbability>28</precipitationProbability>
          <precipitationDesc>Drizzle</precipitationDesc>
          <rainFall>0.00</rainFall>
          <snowFall>*</snowFall>
          <airInfo>32</airInfo>
          <airDescription>Damp</airDescription>
          <windSpeed>18.26</windSpeed>
          <windDirection>163</windDirection>
          <windDesc>South</windDesc>
          <windDescShort>S</windDescShort>
          <uvIndex>0</uvIndex>
          <uvDesc>Minimal</uvDesc>
          <barometerPressure>1007.17</barometerPressure>
          <icon>18</icon>
          <iconName>sprinkles</iconName>
          <iconLink>
            https://weather.cit.api.here.com/static/weather/icon/27.png
          </iconLink>
        </forecast>
        <forecast utcTime="2013-12-05T00:00:00.00-06:00" weekday="Thursday" dayOfWeek="5">
          <daylight>D</daylight>
          <description>Sprinkles late. High level clouds. Cool.</description>
          <skyInfo>12</skyInfo>
          <skyDescription>High level clouds</skyDescription>
          <temperatureDesc>Cool</temperatureDesc>
          <comfort>-6.32</comfort>
          <highTemperature>8.90</highTemperature>
          <lowTemperature>-3.40</lowTemperature>
          <humidity>55</humidity>
          <dewPoint>-8.74</dewPoint>
          <precipitationProbability>18</precipitationProbability>
          <precipitationDesc>Sprinkles late</precipitationDesc>
          <rainFall>*</rainFall>
          <snowFall>*</snowFall>
          <airInfo>*</airInfo>
          <airDescription/>
          <windSpeed>21.96</windSpeed>
          <windDirection>276</windDirection>
          <windDesc>West</windDesc>
          <windDescShort>W</windDescShort>
          <uvIndex>0</uvIndex>
          <uvDesc>Minimal</uvDesc>
          <barometerPressure>1012.06</barometerPressure>
          <icon>18</icon>
          <iconName>sprinkles</iconName>
          <iconLink>
            https://weather.cit.api.here.com/static/weather/icon/27.png
          </iconLink>
        </forecast>
        <forecast>
          ---remaining observations removed to shorten document
        </forecast>
      </forecastLocation>
    </dailyForecasts>
    <feedCreation>2013-11-21T13:10:51.272Z</feedCreation>
    <metric>true</metric>
  </WeatherReport>

For more details about responses to this type of request, see Report Response.