Destination Weather API Developer's Guide

Astronomy Forecast Example

This section provides an example of an astronomy forecast.

Note: This example uses a HERE token to authenticate your request. For the available authentication options, see the Identity & Access Management Developer Guide.

User Story

The user wants to obtain information on sun and moon rise and set times for Chicago, Illinois.

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_astronomy to request astronomy information
  name – indicates the name of the city for which the query requests a weather report

Request

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

curl https://weather.cc.api.here.com/weather/1.0/report.json
?product=forecast_astronomy
&name=Chicago
-H "Authorization: Bearer {YOUR_TOKEN}"

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

curl https://weather.cc.api.here.com/weather/1.0/report.xml
?product=forecast_astronomy
&name=Chicago
-H "Authorization: Bearer {YOUR_TOKEN}"

Response

The response to the request contains:

  • astronomy information for Chicago, Illinois

The example response in JSON format is as follows:

{
  "astronomy": {
  "astronomy": [
    {
    "sunrise": "7:12AM",
    "sunset": "4:14PM",
    "moonrise": "12:25PM",
    "moonset": "12:20AM",
    "moonPhase": 0.54,
    "moonPhaseDesc": "First Quarter",
    "iconName": "cw_first_qtr",
    "city": "Chicago",
    "latitude": 41.83,
    "longitude": -87.68,
    "utcTime": "2013-12-10T00:00:00.00-06:00"
    },
    {
    "sunrise": "7:13AM",
    "sunset": "4:14PM",
    "moonrise": "12:57PM",
    "moonset": "1:25AM",
    "moonPhase": 0.645,
    "moonPhaseDesc": "Waxing gibbous",
    "iconName": "cw_waxing_gibbous",
    "city": "Chicago",
    "latitude": 41.83,
    "longitude": -87.68,
    "utcTime": "2013-12-11T00:00:00.00-06:00"
    },
    {
    "sunrise": "7:14AM",
    "sunset": "4:14PM",
    "moonrise": "1:30PM",
    "moonset": "2:28AM",
    "moonPhase": 0.741,
    "moonPhaseDesc": "Waxing gibbous",
    "iconName": "cw_waxing_gibbous",
    "city": "Chicago",
    "latitude": 41.83,
    "longitude": -87.68,
    "utcTime": "2013-12-12T00:00:00.00-06:00"
    },
    {
    "sunrise": "7:14AM",
    "sunset": "4:14PM",
    "moonrise": "2:05PM",
    "moonset": "3:30AM",
    "moonPhase": 0.825,
    "moonPhaseDesc": "Waxing gibbous",
    "iconName": "cw_waxing_gibbous",
    "city": "Chicago",
    "latitude": 41.83,
    "longitude": -87.68,
    "utcTime": "2013-12-13T00:00:00.00-06:00"
    },
    {
    "sunrise": "7:15AM",
    "sunset": "4:15PM",
    "moonrise": "2:43PM",
    "moonset": "4:28AM",
    "moonPhase": 0.895,
    "moonPhaseDesc": "Waxing gibbous",
    "iconName": "cw_waxing_gibbous",
    "city": "Chicago",
    "latitude": 41.83,
    "longitude": -87.68,
    "utcTime": "2013-12-14T00:00:00.00-06:00"
    },
    {
    "sunrise": "7:16AM",
    "sunset": "4:15PM",
    "moonrise": "3:26PM",
    "moonset": "5:26AM",
    "moonPhase": 0.947,
    "moonPhaseDesc": "Full moon",
    "iconName": "cw_full_moon",
    "city": "Chicago",
    "latitude": 41.83,
    "longitude": -87.68,
    "utcTime": "2013-12-15T00:00:00.00-06:00"
    },
    {
    "sunrise": "7:17AM",
    "sunset": "4:15PM",
    "moonrise": "4:12PM",
    "moonset": "6:18AM",
    "moonPhase": 0.981,
    "moonPhaseDesc": "Full moon",
    "iconName": "cw_full_moon",
    "city": "Chicago",
    "latitude": 41.83,
    "longitude": -87.68,
    "utcTime": "2013-12-16T00:00:00.00-06:00"
    },
    {
    "sunrise": "7:17AM",
    "sunset": "4:15PM",
    "moonrise": "5:02PM",
    "moonset": "7:07AM",
    "moonPhase": 0.998,
    "moonPhaseDesc": "Full moon",
    "iconName": "cw_full_moon",
    "city": "Chicago",
    "latitude": 41.83,
    "longitude": -87.68,
    "utcTime": "2013-12-17T00:00:00.00-06:00"
    }
  ],
  "country": "United States",
  "state": "Illinois",
  "city": "Chicago",
  "latitude": 41.85003,
  "longitude": -87.65005,
  "timezone": -6
  },
  "feedCreation": "2013-12-10T15:44:37.120",
  "metric": true
}

The example response in XML format is as follows:

<WeatherReport>
  <astronomy timezone="-6" longitude="-87.65005" latitude="41.85003" city="Chicago" state="Illinois" country="United States">
    <astronomy utcTime="2013-12-10T00:00:00.00-06:00" longitude="-87.68" latitude="41.83" city="Chicago">
      <sunrise>7:12AM</sunrise>
      <sunset>4:14PM</sunset>
      <moonrise>12:25PM</moonrise>
      <moonset>12:20AM</moonset>
      <moonPhase>0.540</moonPhase>
      <moonPhaseDesc>First Quarter</moonPhaseDesc>
      <iconName>cw_first_qtr</iconName>
    </astronomy>
    <astronomy utcTime="2013-12-11T00:00:00.00-06:00" longitude="-87.68" latitude="41.83" city="Chicago">
      <sunrise>7:13AM</sunrise>
      <sunset>4:14PM</sunset>
      <moonrise>12:57PM</moonrise>
      <moonset>1:25AM</moonset>
      <moonPhase>0.645</moonPhase>
      <moonPhaseDesc>Waxing gibbous</moonPhaseDesc>
      <iconName>cw_waxing_gibbous</iconName>
    </astronomy>
    <astronomy utcTime="2013-12-12T00:00:00.00-06:00" longitude="-87.68" latitude="41.83" city="Chicago">
      <sunrise>7:14AM</sunrise>
      <sunset>4:14PM</sunset>
      <moonrise>1:30PM</moonrise>
      <moonset>2:28AM</moonset>
      <moonPhase>0.741</moonPhase>
      <moonPhaseDesc>Waxing gibbous</moonPhaseDesc>
      <iconName>cw_waxing_gibbous</iconName>
    </astronomy>
    <astronomy utcTime="2013-12-13T00:00:00.00-06:00" longitude="-87.68" latitude="41.83" city="Chicago">
      <sunrise>7:14AM</sunrise>
      <sunset>4:14PM</sunset>
      <moonrise>2:05PM</moonrise>
      <moonset>3:30AM</moonset>
      <moonPhase>0.825</moonPhase>
      <moonPhaseDesc>Waxing gibbous</moonPhaseDesc>
      <iconName>cw_waxing_gibbous</iconName>
    </astronomy>
    <astronomy utcTime="2013-12-14T00:00:00.00-06:00" longitude="-87.68" latitude="41.83" city="Chicago">
      <sunrise>7:15AM</sunrise>
      <sunset>4:15PM</sunset>
      <moonrise>2:43PM</moonrise>
      <moonset>4:28AM</moonset>
      <moonPhase>0.895</moonPhase>
      <moonPhaseDesc>Waxing gibbous</moonPhaseDesc>
      <iconName>cw_waxing_gibbous</iconName>
    </astronomy>
    <astronomy utcTime="2013-12-15T00:00:00.00-06:00" longitude="-87.68" latitude="41.83" city="Chicago">
      <sunrise>7:16AM</sunrise>
      <sunset>4:15PM</sunset>
      <moonrise>3:26PM</moonrise>
      <moonset>5:26AM</moonset>
      <moonPhase>0.947</moonPhase>
      <moonPhaseDesc>Full moon</moonPhaseDesc>
      <iconName>cw_full_moon</iconName>
    </astronomy>
    <astronomy utcTime="2013-12-16T00:00:00.00-06:00" longitude="-87.68" latitude="41.83" city="Chicago">
      <sunrise>7:17AM</sunrise>
      <sunset>4:15PM</sunset>
      <moonrise>4:12PM</moonrise>
      <moonset>6:18AM</moonset>
      <moonPhase>0.981</moonPhase>
      <moonPhaseDesc>Full moon</moonPhaseDesc>
      <iconName>cw_full_moon</iconName>
    </astronomy>
    <astronomy utcTime="2013-12-17T00:00:00.00-06:00" longitude="-87.68" latitude="41.83" city="Chicago">
      <sunrise>7:17AM</sunrise>
      <sunset>4:15PM</sunset>
      <moonrise>5:02PM</moonrise>
      <moonset>7:07AM</moonset>
      <moonPhase>0.998</moonPhase>
      <moonPhaseDesc>Full moon</moonPhaseDesc>
      <iconName>cw_full_moon</iconName>
    </astronomy>
  </astronomy>
  <feedCreation>2013-12-10T15:49:53.254Z</feedCreation>
  <metric>true</metric>
</WeatherReport>

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