# Sun Position API

> Sun Position calculates the sun altitude and azimuth, plus compass bearing, for any geographic coordinates and time. Provide latitude and longitude to read sun elevation angles and daylight status; paid plans add panel aiming angles and shadow ratios.

**Endpoint:** `GET https://api.apiverve.com/v1/sunposition`  
**Category:** Astrology  
**Cost:** 2 credits per call  
**Canonical page:** https://apiverve.com/marketplace/sunposition

## Overview

A solar position API. Sun Position works by analyzing the location provided and calculating sun position data. It uses advanced algorithms to calculate data such as the sun's altitude and azimuth (and, on paid plans, its distance) for the location and returns the sun position data.

## Authentication

Every call carries your key in an `x-api-key` header. The same key works across the whole
APIVerve catalog — there are no per-API subscriptions. Responses always use the same three
top-level keys: `status`, `error`, and `data`.

## Example request

```bash
curl "https://api.apiverve.com/v1/sunposition?lat=37.7749&lon=-122.4194&date=01-16-2026&time=14%3A30&timezone=America%2FLos_Angeles" \
  -H "x-api-key: YOUR_API_KEY"
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `lat` | number | Yes | The latitude of the location. range -90-90 |
| `lon` | number | Yes | The longitude of the location. range -180-180 |
| `date` | string | No | The date to get the sun position data for (MM-DD-YYYY or YYYY-MM-DD). An ISO date-time such as 2026-06-21T13:30:00 is also accepted and supplies the time; with Z or an offset it is read as that exact instant. Years 1700 to 2300 are supported. datetime. Premium field |
| `time` | string | No | The time of day for the calculation (HH:mm, 24-hour; HH:mm:ss and 12-hour times such as 1:30 PM are also accepted, seconds are ignored), read in the timezone of the coordinates. Defaults to 00:00 if not provided. time |
| `timezone` | string | No | IANA timezone to read the date and time in, such as America/Los_Angeles. Defaults to the timezone of the coordinates. timezone |

## Response fields

- `date` — string · Date the position was calculated for
- `time` — string · Time of day the position was calculated for
- `timezone` — string · IANA timezone the date and time were read in, resolved from the coordinates unless one was given
- `timestampUTC` — string · The instant the position was calculated for, in UTC, so the answer is unambiguous
- `coordinates` — object · The point on Earth the position was calculated from
  - `coordinates.latitude` — number · Latitude used for the calculation
  - `coordinates.longitude` — number · Longitude used for the calculation
- `sun` — object · Where the sun sits in the sky at that time and place
  - `sun.altitude` — number · Height of the sun above the horizon, in radians; negative when the sun is below the horizon. Multiply by 180/PI for degrees
  - `sun.azimuth` — number · Direction of the sun, in radians measured from due south and increasing westward. Multiply by 180/PI for degrees, then add 180 for a compass bearing
  - `sun.altitudeDegrees` — number · Height of the sun above the horizon in degrees; negative when below
  - `sun.azimuthDegrees` — number · Direction of the sun in degrees from due south, increasing westward
  - `sun.compassBearing` — number · Direction of the sun as a compass bearing, 0 for north and 180 for south
  - `sun.isDaylight` — boolean · Whether the sun is above the horizon at this time and place
  - `sun.declination` — number · Angle of the sun north or south of the celestial equator, in degrees · (premium)
  - `sun.rightAscension` — number · Position of the sun along the celestial equator, in hours · (premium)
  - `sun.hourAngle` — number · Hours since the sun crossed the local meridian; negative before solar noon · (premium)
  - `sun.distance` — number · Distance from Earth to the sun in astronomical units · (premium)
- `equationOfTime` — number · Minutes a sundial reads ahead of the clock at this date; negative when it reads behind · (premium)
- `airMass` — number · How much atmosphere the sunlight crosses, as a multiple of straight overhead; null after dark · (premium)
- `clearSky` — object · Cloudless-sky irradiance estimate in watts per square metre; null after dark · (premium)
  - `clearSky.directNormal` — number · Irradiance on a surface aimed straight at the sun, which is what a tracker sees · (premium)
  - `clearSky.globalHorizontal` — number · Irradiance on a flat horizontal surface · (premium)
- `shadowRatio` — number · Length of the shadow cast by an object, per unit of its height; null after dark · (premium)
- `panelAim` — object · Where to point a solar panel to face the sun squarely at this moment; null after dark · (premium)
  - `panelAim.tilt` — number · Degrees to tilt the panel back from vertical · (premium)
  - `panelAim.azimuth` — number · Compass bearing to point the panel at · (premium)

## Sample response

```json
{
  "status": "ok",
  "error": null,
  "data": {
    "date": "01-16-2026",
    "time": "14:30",
    "timezone": "America/Los_Angeles",
    "timestampUTC": "2026-01-16T22:30:00.000Z",
    "coordinates": {
      "latitude": 37.7749,
      "longitude": -122.4194
    },
    "sun": {
      "altitude": 0.41616137328975444,
      "azimuth": 0.5817558808515568,
      "altitudeDegrees": 23.844,
      "azimuthDegrees": 33.332,
      "compassBearing": 213.332,
      "isDaylight": true,
      "declination": -20.7961,
      "rightAscension": 19.9228,
      "hourAngle": 2.174,
      "distance": 0.983786
    },
    "equationOfTime": -9.88,
    "airMass": 2.454,
    "clearSky": {
      "directNormal": 702.4,
      "globalHorizontal": 284.9
    },
    "shadowRatio": 2.254,
    "panelAim": {
      "tilt": 66.07,
      "azimuth": 213.44
    }
  }
}
```

## Use cases

- **Golden Hour Photo Planning** — To help photographers capture natural light, mobile photography guides check solar altitude and compass bearings to forecast golden hour windows.
- **Smart Blind Automation** — Lower automated window shades when incoming sun altitude and bearing show direct glare striking specific building facades.
- **Architectural Glare Analysis** — Building design software computes sun elevation angles across the day to evaluate interior daylighting and orient office windows.
- **Athletic Field Orientation** — When setting up temporary sports pitches, venue managers check compass bearings to align player sightlines away from the setting sun.

## SDKs

- **npm** — `npm install @apiverve/sunposition` (https://www.npmjs.com/package/@apiverve/sunposition)
- **PyPI** — `pip install apiverve-sunposition` (https://pypi.org/project/apiverve-sunposition/)
- **NuGet** — `dotnet add package APIVerve.API.SunPosition` (https://www.nuget.org/packages/APIVerve.API.SunPosition)
- **Source** — https://github.com/apiverve/sunposition-api

## More

- Full reference: https://docs.apiverve.com/ref/sunposition
- Get an API key: https://dashboard.apiverve.com
- Full catalog: https://apiverve.com/marketplace
