For the complete documentation index, see llms.txt. This page is also available as Markdown.

🌐Positions

Where the Sun, the Moon and the planets are

Returns where each requested body appears from the observer's location, sampled between two instants.

One request covers as many bodies and as many instants as needed. Omit bodies to get all of them; set step to sample more finely than once a day.

Positions of one or more bodies over a span of time

get

Returns where each requested body appears from the observer's location, sampled from from to to at intervals of step.

Sampling is the main thing v3 adds. v2 could only return one position per day at a fixed time of day; step accepts any ISO 8601 duration, so an altitude curve is one request rather than twenty-four.

Authorizations
AuthorizationstringRequired

The application key, sent as Authorization: Bearer <key>. Keys are never accepted in the query string, where they would be recorded in logs and browser history.

Query parameters
latitudenumber · min: -90 · max: 90Required

Latitude of the observer, in degrees, positive north.

Example: 51.4779
longitudenumber · min: -180 · max: 180Required

Longitude of the observer, in degrees, positive east.

Example: -0.0015
elevationnumber · min: -500 · max: 9000Optional

Height of the observer above sea level, in metres. Defaults to sea level. The upper bound covers the highest permanent observatories.

Default: 0
fromstringRequired

First instant to sample, as an ISO 8601 date or date-time. A bare date means midnight UTC on that date.

Example: 2024-06-21T00:00:00Z
tostringRequired

Last instant to sample. Must not precede from.

Example: 2024-06-22T00:00:00Z
stepstringOptional

Interval between samples, as an ISO 8601 duration. P1D reproduces v2's one-sample-per-day behaviour, which is the default.

Default: P1DExample: PT1HPattern: ^P(?!$)(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?$
timezonestringOptional

IANA zone the returned instants are expressed in. auto derives it from the observer's coordinates, which is what v2 always did and remains the default. UTC is the unambiguous choice.

Default: autoExample: auto
originstring · enumOptional

Whether to measure from the observer's own position or from the centre of the Earth. The difference is parallax, worth up to about a degree for the Moon and arcseconds for the planets.

Default: topocentricPossible values:
refractionstring · enumOptional

Whether the altitude accounts for the atmosphere bending light near the horizon. none gives the geometric altitude.

Default: standardPossible values:
includestringOptional

Optional extras, comma separated. formatted adds a parallel block of sexagesimal strings for each angle, which v2 always sent whether or not the caller wanted them.

Example: formatted
limitinteger · min: 1 · max: 10000Optional

Most samples to return per body before paginating.

Default: 1000
cursorstringOptional

Opaque cursor from meta.sampling.nextCursor.

Responses
200

Positions for each requested body.

application/json
get/positions
GET /api/v3/positions?latitude=51.4779&longitude=-0.0015&from=2024-06-21T00%3A00%3A00Z&to=2024-06-22T00%3A00%3A00Z HTTP/1.1
Host: api.astronomyapi.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
  "meta": {
    "observer": {
      "latitude": 51.4779,
      "longitude": -0.0015,
      "elevation": 0
    },
    "timezone": "Europe/London",
    "units": {
      "rightAscension": "hours",
      "declination": "degrees",
      "altitude": "degrees",
      "azimuth": "degrees",
      "distance": "au"
    },
    "frames": {
      "equatorial": "J2000",
      "horizontal": "apparent, refracted"
    },
    "sampling": {
      "from": "2024-06-21T11:00:00Z",
      "to": "2024-06-21T11:00:00Z",
      "step": "PT1H",
      "count": 1
    }
  },
  "data": [
    {
      "body": {
        "id": "mars",
        "name": "Mars"
      },
      "samples": [
        {
          "time": "2024-06-21T11:00:00Z",
          "rightAscension": 2.44012,
          "declination": 13.41983,
          "altitude": 41.26454,
          "azimuth": 232.99871,
          "distance": {
            "au": 1.7782248,
            "km": 266018470.2
          },
          "constellation": {
            "abbreviation": "Ari",
            "name": "Aries"
          },
          "elongation": 51.52915,
          "magnitude": 1.00953
        }
      ]
    }
  ]
}

Examples

Mars right now, from London:

The Moon's altitude every fifteen minutes through a night, in UTC:

Everything visible, once a day for a week, with sexagesimal strings alongside the numbers:

Notes

earth is not available here. Seen from the Earth it is at zero distance and has no direction, so v2's answer for it was arbitrary. Asking for it returns 422.

Altitude may be negative. A body below the horizon is a legitimate answer, not an error. Filter on altitude > 0 if only what is up matters.

Refraction is applied by default, because that is where a body appears rather than where it geometrically is. Pass refraction=none for the geometric altitude. The difference is about half a degree at the horizon and negligible overhead.

Large spans paginate. With a fine step a long span can run to tens of thousands of samples; when limit is reached, meta.sampling.nextCursor carries the continuation.

Last updated