Skip to main content

thirdtrail

Python client for the thirdtrail APIs: sun, moon, twilight, solar irradiance and tides for any point on Earth. Sun and moon times are corrected for the elevation you pass in.

pip install thirdtrail
from thirdtrail import Client

tt = Client(api_key="tt_live_…")

for day in tt.ephemerides(lat=53.3498, lon=-6.2603, elevation=20):
    print(day.date, day.sun.rise, day.sun.set)

Why elevation

Most sunrise APIs answer for an observer standing at sea level. The higher you are, the further you can see, and the earlier the sun clears the horizon.

At the Cliffs of Moher (214 m), which face west over the Atlantic, sunset on 21 September 2026 is about three minutes later than the sea-level answer, and every golden- and blue-hour boundary moves with it:

sea level at 214 m
sunset 19:38:45 19:41:52
golden hour, evening end 20:03:35 20:06:43
moonset 00:38:33 00:43:08

Golden hour lasts 20 to 40 minutes, so three minutes is a noticeable share of it. Pass elevation whenever you know it. It is your height above the horizon you are looking across: on a sea cliff, your height above the sea; in a town on a plateau, close to zero.

What you get

day.sun.rise                        # datetime, with its timezone offset intact
day.sun.golden_hour.morning.start
day.moon.phase.name                 # "Waxing Gibbous"
day.moon.phase.illumination         # 0.7376

Timestamps arrive as aware datetime objects, not strings. Anything the client does not model is still available on day.raw and day.response, so you can use a new server-side field before the client catches up.

Endpoints

tt.ephemerides(lat=…, lon=…, elevation=…, days=7)     # sun + moon + twilight
tt.prayer_times(lat=…, lon=…, school="mwl")           # mwl, isna, egyptian, uaq, karachi
tt.solar(lat=…, lon=…, timestamp=…)                   # position + irradiance
tt.solar_path(lat=…, lon=…, interval="5m")            # the sun's arc, sampled
tt.solar_dli(lat=…, lon=…, from_date=…, to_date=…)    # Daily Light Integral
tt.tide_heights(lat=…, lon=…, step="10m")             # water height series
tt.tide_extremes(lat=…, lon=…)                        # high and low waters
tt.tide_window(lat=…, lon=…, elevation=…)             # tides + sun + moon
tt.tide_constituents(lat=…, lon=…)                    # harmonic constants

Tides take no elevation, with one exception

tide_heights and tide_extremes have no elevation parameter on purpose, because how high you stand doesn't change the ocean surface. If you pass one, you get a TypeError instead of having it silently ignored.

tide_window is the exception, because half of what it returns is sun and moon data:

for day in tt.tide_window(lat=52.9715, lon=-9.4309, elevation=214, days=3):
    print(day.date, day.sun.golden_hour.morning.start)
    for t in day.low_waters:
        print("  low water", t.time, t.height_m)

Tide heights are metres relative to mean sea level, not chart datum, and they exclude weather-driven surge. Not for navigation.

Errors

Each kind of failure has its own exception class, so you can catch the one you care about instead of parsing error messages:

from thirdtrail import PlanLimitExceeded

try:
    tt.tide_extremes(lat=51.5, lon=-2.7, days=90)
except PlanLimitExceeded as e:
    tt.tide_extremes(lat=51.5, lon=-2.7, days=e.limit)   # e.limit == 31

AuthenticationError (401), PermissionDenied (403, a tier you are not on), PlanLimitExceeded and InvalidRequest (400), RateLimited (429), DataUnavailable (503), ServerError (5xx). All subclass ThirdtrailError.

Transient failures and 429s are retried with backoff. Plan limits are not retried, because the same request would fail the same way every time.

Keys

Create one at thirdtrail.life/apis/keys/. A key belongs to one subscription, so it works with one API; a Tides key calling a solar endpoint gets PermissionDenied.

Every API has a free tier.

Not covered yet

The client doesn't cover the bulk (POST) endpoints, iCalendar feeds or webhook management yet. For those, call the REST API directly; the full contract is published as OpenAPI 3.1.

Using an AI agent? There is an MCP server that exposes the same data as tools.

Licence

MIT

Metadata

Release files for thirdtrail 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for thirdtrail 0.1.2
File Size Uploaded Provenance Actions
thirdtrail-0.1.2.tar.gz 53.9 kB With provenance Details for thirdtrail-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for thirdtrail 0.1.2
File Interpreter ABI Platform Actions
thirdtrail-0.1.2-py3-none-any.whl Python 3 none any Details for thirdtrail-0.1.2-py3-none-any.whl

Total release size: 66.1 kB

Release files / thirdtrail-0.1.2.tar.gz

Download URL thirdtrail-0.1.2.tar.gz
Size 53.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b97ea451616a5539b2bb29518941bc529a33e58b9643e02c01d43051689bea3b
BLAKE2b-256 checksum
How to use checksums
4312e21df4a6f879138733504c7687145286f93fb933c559f76c971e27e15d0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

Release files / thirdtrail-0.1.2-py3-none-any.whl

Download URL thirdtrail-0.1.2-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b1479ff1b66d9f455f0db3fd8f8341d07849b95bc6f7b316edb8a95198f5a24
BLAKE2b-256 checksum
How to use checksums
283582e8fb47d0a124d21897296e53e7efab6833f187eacf37f00ce069f9d24e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

Security for thirdtrail 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for thirdtrail-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page