How to request an astronomy forecast
This section provides an example of an astronomy forecast request with the HERE Destination Weather API.
Note
This example uses a HERE token to authenticate your request. For the available authentication options, see the Identity and 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 |
|---|---|
Parameters products: Indicates what kind of report the query requests; in this example, the query uses the parameter value forecastAstronomy to request astronomy information. q: Indicates the location name for which the query requests a weather report. |
Request
The following code block demonstrates the complete request, specifying that the response data is to be delivered in JSON.
curl https://weather.hereapi.com/v3/report
?products=forecastAstronomy
&q=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:
{
"places": [
{
"astronomyForecasts": [
{
"place": {
"address": {
"countryCode": "USA",
"countryName": "United States",
"state": "Illinois",
"city": "Chicago"
},
"location": {
"lat": 41.85003,
"lng": -87.65005
}
},
"forecasts": [
{
"sunRise": "05:15:00",
"sunSet": "20:25:00",
"moonRise": "07:54:00",
"moonSet": "23:40:00",
"moonPhase": "0.072",
"moonPhaseDescription": "Waxing crescent",
"iconName": "cw_waxing_crescent",
"time": "2024-06-09T00:00:00.000-05:00"
},
{
"sunRise": "05:15:00",
"sunSet": "20:25:00",
"moonRise": "09:02:00",
"moonPhase": "0.134",
"moonPhaseDescription": "Waxing crescent",
"iconName": "cw_waxing_crescent",
"time": "2024-06-10T00:00:00.000-05:00"
},
{
"sunRise": "05:15:00",
"sunSet": "20:26:00",
"moonRise": "10:09:00",
"moonSet": "00:09:00",
"moonPhase": "0.209",
"moonPhaseDescription": "Waxing crescent",
"iconName": "cw_waxing_crescent",
"time": "2024-06-11T00:00:00.000-05:00"
},
{
"sunRise": "05:15:00",
"sunSet": "20:26:00",
"moonRise": "11:13:00",
"moonSet": "00:33:00",
"moonPhase": "0.294",
"moonPhaseDescription": "Waxing crescent",
"iconName": "cw_waxing_crescent",
"time": "2024-06-12T00:00:00.000-05:00"
},
{
"sunRise": "05:15:00",
"sunSet": "20:26:00",
"moonRise": "12:15:00",
"moonSet": "00:54:00",
"moonPhase": "0.385",
"moonPhaseDescription": "Waxing crescent",
"iconName": "cw_waxing_crescent",
"time": "2024-06-13T00:00:00.000-05:00"
},
{
"sunRise": "05:15:00",
"sunSet": "20:27:00",
"moonRise": "13:16:00",
"moonSet": "01:13:00",
"moonPhase": "0.479",
"moonPhaseDescription": "First Quarter",
"iconName": "cw_first_qtr",
"time": "2024-06-14T00:00:00.000-05:00"
},
{
"sunRise": "05:15:00",
"sunSet": "20:27:00",
"moonRise": "14:16:00",
"moonSet": "01:31:00",
"moonPhase": "0.573",
"moonPhaseDescription": "First Quarter",
"iconName": "cw_first_qtr",
"time": "2024-06-15T00:00:00.000-05:00"
},
{
"sunRise": "05:15:00",
"sunSet": "20:28:00",
"moonRise": "15:18:00",
"moonSet": "01:49:00",
"moonPhase": "0.666",
"moonPhaseDescription": "Waxing gibbous",
"iconName": "cw_waxing_gibbous",
"time": "2024-06-16T00:00:00.000-05:00"
}
]
}
]
}
]
}For more details about responses to this type of request, see Report response For more information, see Weather report.
Updated 11 days ago