astronomy – Get Information About Astronomical Objects

The astronomy service can be used retrieve the sunrise, sunset, moonrise, moonset, solar noon and twilight times for all locations in our database. The service also returns the azimuth of the events, the altitude, and the distance to the sun for the noon event.

Further information about several other parameters, including the various twilight events can be found on the About the Sunrise and Sunset Calculator page.

Note

For locations north of the arctic circle, or south of the antarctic circle, the assumptions that there is exactly one sunrise and one sunset event per day, or that the sun will rise before it sets, are not true! The same is the case for twilight events.

Depending on the date, there may be two sunset events on the same day or the sun first sets and rises shortly thereafter. For an example of this unusual sequence, please see the sunrise and sunset times for Svalbard during the month of August.

This service can be tested with the Query Builder.

Request Parameters. 

NameDescriptionRequired
object

Specify which astronomical object you are interested in. Currently, only sun and moon are supported.

Type: String/Astronomical Object Id

Yes
placeid

Specify the ID of the location you would like to retrieve information for. To retrieve the information for multiple places, the corresponding IDs can either be specified as a comma separated list, or by supplying the parameter multiple times (or any combination).

Note: It is also possible to specify coordinates or IATA/ICAO codes for airports, see the documentation for the type Location Id for detailed information.

Type: String/Location Id

Yes
startdt

Specify the ISO 8601 date for the first date you are interested in.

Type: String/ISO8601 Date

Yes
enddt

The last date you are interested in. The service can be used to calculate data for a maximum of 31 days in a row. If the end date is omitted, only one day is retrieved.

Type: String/ISO8601 Date

No
types

Selection of which astronomical events you are interested in. To combine multiple classes, either separate them with commas or repeat the parameter with a different value. A negation can be expressed by prefixing the value with a tilde (~) character. Values are combined in the order they are supplied.

Type: String/Astronomy Event Class

No
geo

Return longitude and latitude for the geo object.

Type: Boolean

Accepted values: 0 or 1

Default value: 1

No
isotime

Adds time stamps (local time) in ISO 8601 format to all events.

Type: Boolean

Accepted values: 0 or 1

Default value: 0

No
lang

The preferred language for the texts. An error will be raised if the language code cannot be recognized. In case the text for a specific event cannot be retrieved in the requested language it will be returned in English instead. This is also the default language.

In case you have specific needs for a certain language/translation, please email api@timeanddate.com.

Type: String/ISO639 Language Code

Default value: en

Note

Due to technical limitations, time zone names cannot be translated at the moment.
No
radius

Search radius for translating coordinates (parameter placeid) to locations. Coordinates that could not be translated will yield results for the actual geographical position – if you would like to query for times at an exact location, specify a radius of zero (0).

Type: Integer

Default value: infinite (but only locations within the same country and time zone are considered)

No
utctime

Adds UTC time stamps in ISO 8601 format to all events.

Type: Boolean

Accepted values: 0 or 1

Default value: 0

No
template

Specify the name of a template if you want the result rendered in a specific format (e.g. CSV). The number at the end of the value specifies what types of column you want returned.

Type: String

Accepted values: csvN or csvsimpleN (where N is a number between 1 and 4, see Supported Text Templates below)

Default value: None

No
csvstyle

When returning a CSV template you can set this parameter to choose whether the result should be separated by a comma or a semicolon.

Type: Number

Accepted values: 1 (comma, US-style) or 2 (semicolon, Euro-style)

Default value: 1

No

See also the section called “General Parameters”.

Response Elements. 

NameDescription
location (XML), locations (JSON)

This element wraps the information for the locations in the request. For the XML format, it will be repeated multiple times, while for JSON, it is modeled as an array of objects with the same content.

Type: Array of LocationAstroType

Supported Text Templates. 

In addition to retrieving these text templates via our API, you can also try out and download this data from our Data Download page.

csvsimpleN

To use this template, specify this parameter combination: out=text&template=csvsimpleN, where N is the identifier for which columns you want returned (see Table 4.1 below).

This CSV-template returns a simplified format of the requested astronomy result. In this template, there will be only one row per date for the requested country and year. By default, the result will be formatted in US CSV-format (comma as separator). It is possible to return the CSV in European CSV-format (semicolon as separator) by including csvstyle=2 in the request. Several different options are available to define which columns you want to include in your result. Some options are only available for the sun object type. See Table 4.1 below to see which columns are included for which object types.

csvN

To use this template, specify this parameter combination: out=text&template=csvN, where N is the identifier for which columns you want returned (see Table 4.1 below).

This CSV-template returns a more advanced format of the requested astronomy result. In this template, there will be multiple lines per date. Each line for a date will be either for Set or Rise. This is useful for cases where there can be more than one rise and set in a day. The Line column will contain a number for each row in a date. By default, the result will be formatted in US CSV-format (comma as separator). It is possible to return the CSV in European CSV-format (semicolon as separator) by including csvstyle=2 in the request. Several different options are available to define which columns you want to include in your result. Some options are only available for the sun object type. See Table 4.1 below to see which columns are included for which object types.

Table 4.1. Supported Columns for astronomy CSV Templates

This table shows the supported columns for the given Astronomical Object Id. template parameters are shown horizontally, columns included in the result are shown vertically.
Columncsv1 / csvsimple1csv2 / csvsimple2csv3 / csvsimple3csv4 / csvsimple4
Datesun | moonsun | moonsunsun | moon
Risesun | moonsun | moonsunsun | moon
Setsun | moonsun | moonsunsun | moon
DayLengthsunsun sun
DayLengthDiffsunsun sun
Meridiansun | moon  sun | moon
Altitudesun | moon  sun | moon
Distancesun | moon  sun | moon
Illuminatedmoon  moon
Phasemoonmoon moon
PhaseTimemoonmoon moon
RiseAzimuth sun | moon sun | moon
SetAzimuth sun | moon sun | moon
Twi18Begin  sunsun
Twi18Duration   sun
Twi18End  sunsun
Twi12Begin  sunsun
Twi12Duration   sun
Twi12End  sunsun
Twi6Begin  sunsun
Twi6Duration   sun
Twi6End  sunsun
Linesun | moonsun | moonsun | moonsun | moon


Example JSON Request. 

https://api.xmltime.com/astronomy?object=sun&placeid=152&startdt=2012-03-19&enddt=2012-03-20&types=all&version=2&out=json&prettyprint=1&accesskey={KEY}&expires={TIMESTAMP}&signature={SIGNATURE}

Example JSON response

{
  "version": 1,
  "locations": [{
    "id": "152",
    "geo": {
      "name": "Melbourne",
      "state": "Victoria",
      "country": {
        "id": "au",
        "name": "Australia"
      },
      "latitude": -37.814,
      "longitude": 144.963
    },
    "astronomy": {
      "objects": [{
        "name": "sun",
        "days": [{
          "date": "2012-03-19",
          "events": [{
            "type": "antimeridian",
            "utctime": "2012-03-18T14:28",
            "isotime": "2012-03-19T01:28+11:00",
            "hour": 1,
            "min": 28
          },{
            "type": "twi18_start",
            "utctime": "2012-03-18T18:54",
            "isotime": "2012-03-19T05:54+11:00",
            "hour": 5,
            "min": 54
          },{
            "type": "twi12_start",
            "utctime": "2012-03-18T19:25",
            "isotime": "2012-03-19T06:25+11:00",
            "hour": 6,
            "min": 25
          },{
            "type": "twi6_start",
            "utctime": "2012-03-18T19:56",
            "isotime": "2012-03-19T06:56+11:00",
            "hour": 6,
            "min": 56
          },{
            "type": "rise",
            "utctime": "2012-03-18T20:22",
            "isotime": "2012-03-19T07:22+11:00",
            "hour": 7,
            "min": 22,
            "azimuth": 91.3
          },{
            "type": "meridian",
            "utctime": "2012-03-19T02:28",
            "isotime": "2012-03-19T13:28+11:00",
            "hour": 13,
            "min": 28,
            "altitude": 52.6,
            "distance": 148942000
          },{
            "type": "set",
            "utctime": "2012-03-19T08:33",
            "isotime": "2012-03-19T19:33+11:00",
            "hour": 19,
            "min": 33,
            "azimuth": 268.9
          },{
            "type": "twi6_end",
            "utctime": "2012-03-19T08:59",
            "isotime": "2012-03-19T19:59+11:00",
            "hour": 19,
            "min": 59
          },{
            "type": "twi12_end",
            "utctime": "2012-03-19T09:30",
            "isotime": "2012-03-19T20:30+11:00",
            "hour": 20,
            "min": 30
          },{
            "type": "twi18_end",
            "utctime": "2012-03-19T10:01",
            "isotime": "2012-03-19T21:01+11:00",
            "hour": 21,
            "min": 1
          }],
          "daylength": "12:11"
        },{
          "date": "2012-03-20",
          "events": [{
            "type": "antimeridian",
            "utctime": "2012-03-19T14:28",
            "isotime": "2012-03-20T01:28+11:00",
            "hour": 1,
            "min": 28
          },{
            "type": "twi18_start",
            "utctime": "2012-03-19T18:55",
            "isotime": "2012-03-20T05:55+11:00",
            "hour": 5,
            "min": 55
          },{
            "type": "twi12_start",
            "utctime": "2012-03-19T19:26",
            "isotime": "2012-03-20T06:26+11:00",
            "hour": 6,
            "min": 26
          },{
            "type": "twi6_start",
            "utctime": "2012-03-19T19:57",
            "isotime": "2012-03-20T06:57+11:00",
            "hour": 6,
            "min": 57
          },{
            "type": "rise",
            "utctime": "2012-03-19T20:23",
            "isotime": "2012-03-20T07:23+11:00",
            "hour": 7,
            "min": 23,
            "azimuth": 90.8
          },{
            "type": "meridian",
            "utctime": "2012-03-20T02:28",
            "isotime": "2012-03-20T13:28+11:00",
            "hour": 13,
            "min": 28,
            "altitude": 52.2,
            "distance": 148984000
          },{
            "type": "set",
            "utctime": "2012-03-20T08:32",
            "isotime": "2012-03-20T19:32+11:00",
            "hour": 19,
            "min": 32,
            "azimuth": 269.4
          },{
            "type": "twi6_end",
            "utctime": "2012-03-20T08:58",
            "isotime": "2012-03-20T19:58+11:00",
            "hour": 19,
            "min": 58
          },{
            "type": "twi12_end",
            "utctime": "2012-03-20T09:28",
            "isotime": "2012-03-20T20:28+11:00",
            "hour": 20,
            "min": 28
          },{
            "type": "twi18_end",
            "utctime": "2012-03-20T09:59",
            "isotime": "2012-03-20T20:59+11:00",
            "hour": 20,
            "min": 59
          }],
          "daylength": "12:08"
        }]
      }]
    }
  }]
}

Example XML Request. 

https://api.xmltime.com/astronomy?object=sun&placeid=152&startdt=2012-03-19&enddt=2012-03-20&types=all&version=2&out=xml&prettyprint=1&accesskey={KEY}&expires={TIMESTAMP}&signature={SIGNATURE}

Example XML response

<?xml version="1.0" encoding="UTF-8"?>
<data version="1">
  <location id="152">
    <geo>
      <name>Melbourne</name>
      <state>Victoria</state>
      <country id="au">Australia</country>
      <latitude>-37.814</latitude>
      <longitude>144.963</longitude>
    </geo>
    <astronomy>
      <object name="sun">
        <day date="2012-03-19" daylength="12:11">
          <event type="antimeridian" utctime="2012-03-18T14:28" isotime="2012-03-19T01:28+11:00" hour="1" min="28"/>
          <event type="twi18_start" utctime="2012-03-18T18:54" isotime="2012-03-19T05:54+11:00" hour="5" min="54"/>
          <event type="twi12_start" utctime="2012-03-18T19:25" isotime="2012-03-19T06:25+11:00" hour="6" min="25"/>
          <event type="twi6_start" utctime="2012-03-18T19:56" isotime="2012-03-19T06:56+11:00" hour="6" min="56"/>
          <event type="rise" utctime="2012-03-18T20:22" isotime="2012-03-19T07:22+11:00" hour="7" min="22" azimuth="91.3"/>
          <event type="meridian" utctime="2012-03-19T02:28" isotime="2012-03-19T13:28+11:00" hour="13" min="28" altitude="52.6" distance="148942000"/>
          <event type="set" utctime="2012-03-19T08:33" isotime="2012-03-19T19:33+11:00" hour="19" min="33" azimuth="268.9"/>
          <event type="twi6_end" utctime="2012-03-19T08:59" isotime="2012-03-19T19:59+11:00" hour="19" min="59"/>
          <event type="twi12_end" utctime="2012-03-19T09:30" isotime="2012-03-19T20:30+11:00" hour="20" min="30"/>
          <event type="twi18_end" utctime="2012-03-19T10:01" isotime="2012-03-19T21:01+11:00" hour="21" min="1"/>
        </day>
        <day date="2012-03-20" daylength="12:08">
          <event type="antimeridian" utctime="2012-03-19T14:28" isotime="2012-03-20T01:28+11:00" hour="1" min="28"/>
          <event type="twi18_start" utctime="2012-03-19T18:55" isotime="2012-03-20T05:55+11:00" hour="5" min="55"/>
          <event type="twi12_start" utctime="2012-03-19T19:26" isotime="2012-03-20T06:26+11:00" hour="6" min="26"/>
          <event type="twi6_start" utctime="2012-03-19T19:57" isotime="2012-03-20T06:57+11:00" hour="6" min="57"/>
          <event type="rise" utctime="2012-03-19T20:23" isotime="2012-03-20T07:23+11:00" hour="7" min="23" azimuth="90.8"/>
          <event type="meridian" utctime="2012-03-20T02:28" isotime="2012-03-20T13:28+11:00" hour="13" min="28" altitude="52.2" distance="148984000"/>
          <event type="set" utctime="2012-03-20T08:32" isotime="2012-03-20T19:32+11:00" hour="19" min="32" azimuth="269.4"/>
          <event type="twi6_end" utctime="2012-03-20T08:58" isotime="2012-03-20T19:58+11:00" hour="19" min="58"/>
          <event type="twi12_end" utctime="2012-03-20T09:28" isotime="2012-03-20T20:28+11:00" hour="20" min="28"/>
          <event type="twi18_end" utctime="2012-03-20T09:59" isotime="2012-03-20T20:59+11:00" hour="20" min="59"/>
        </day>
      </object>
    </astronomy>
  </location>
</data>

Example Simple CSV Request. 

https://api.xmltime.com/astronomy?object=moon&placeid=152&startdt=2015-01-01&enddt=2015-01-20&types=all&version=2&out=text&template=csvsimple4&accesskey={KEY}&expires={TIMESTAMP}&signature={SIGNATURE}

Example Simple CSV (template=csvsimple4&object=moon) response

		
Date,Rise,Set,RiseAzimuth,SetAzimuth,Meridian,Altitude,Distance,Illuminated,Phase,PhaseTime
2015-01-01,16:58,02:52,69.9,288.2,22:18,35.2,385166,86.0%,waxinggibbous,
2015-01-02,17:57,03:35,67.3,291.4,23:10,33.5,388647,92.6%,waxinggibbous,
2015-01-03,18:52,04:21,66.1,293.3,,,,,waxinggibbous,
2015-01-04,19:43,05:11,66.3,294.0,00:02,32.8,392056,97.1%,waxinggibbous,
2015-01-05,20:29,06:04,67.7,293.3,00:53,33.1,395346,99.4%,fullmoon,15:53
2015-01-06,21:10,06:58,70.1,291.4,01:42,34.4,398426,99.6%,waninggibbous,
2015-01-07,21:48,07:54,73.5,288.5,02:30,36.5,401160,97.8%,waninggibbous,
2015-01-12,,12:28,,266.0,06:08,53.9,403066,65.3%,waninggibbous,
2015-01-13,00:24,13:24,96.4,261.1,06:51,57.8,399999,55.7%,thirdquarter,20:46
2015-01-14,00:56,14:21,101.0,256.6,07:35,61.5,395708,45.7%,waningcrescent,
2015-01-15,01:31,15:19,105.3,252.5,08:22,64.8,390371,35.6%,waningcrescent,
2015-01-21,06:57,20:55,108.5,254.0,13:59,65.5,360099,0.6%,newmoon,00:13
2015-01-22,08:08,21:39,103.8,259.2,14:57,61.5,359738,4.0%,waxingcrescent,
2015-01-23,09:19,22:19,98.1,265.0,15:53,56.9,361225,10.3%,waxingcrescent,
2015-01-26,12:45,,80.2,,18:32,42.9,373343,40.4%,waxingcrescent,
2015-01-27,13:50,00:14,75.2,282.2,19:24,39.1,378464,51.8%,firstquarter,15:48
2015-01-28,14:52,00:53,71.2,286.7,20:16,36.2,383486,62.7%,waxinggibbous,
	

Example Advanced CSV Request. 

https://api.xmltime.com/astronomy?object=moon&placeid=152&startdt=2015-01-01&enddt=2015-01-20&types=all&version=2&out=text&template=csv4&accesskey={KEY}&expires={TIMESTAMP}&signature={SIGNATURE}

Example Advanced CSV (template=csv4&object=moon) response

		
Date,Line,Rise,Set,RiseAzimuth,SetAzimuth,Meridian,Altitude,Distance,Illuminated,Phase,PhaseTime
2015-01-01,1,,02:52,,288.2,22:18,35.2,385166,86.0%,waxinggibbous,
2015-01-01,2,16:58,,0.00,,,,,,,
2015-01-02,1,,03:35,,291.4,23:10,33.5,388647,92.6%,waxinggibbous,
2015-01-03,1,,04:21,,293.3,,,,,waxinggibbous,
2015-01-04,1,,05:11,,294.0,00:02,32.8,392056,97.1%,waxinggibbous,
2015-01-05,1,,06:04,,293.3,00:53,33.1,395346,99.4%,fullmoon,15:53
2015-01-06,1,,06:58,,291.4,01:42,34.4,398426,99.6%,waninggibbous,
2015-01-13,1,00:24,13:24,96.4,261.1,06:51,57.8,399999,55.7%,thirdquarter,20:46
2015-01-21,1,06:57,20:55,108.5,254.0,13:59,65.5,360099,0.6%,newmoon,00:13
2015-01-26,1,12:45,,80.2,,18:32,42.9,373343,40.4%,waxingcrescent,
2015-01-27,1,,00:14,,282.2,19:24,39.1,378464,51.8%,firstquarter,15:48
2015-01-28,1,,00:53,,286.7,20:16,36.2,383486,62.7%,waxinggibbous,
		
	

prev top | next >
Terms & Conditions Copyright © Time and Date AS
All data supplied by timeanddate.com