API Guide
See the full API reference for the complete spec.
The Leonid Space API provides programmatic REST access to our live predictions of space weather indices, atmospheric density grids, and orbital object trajectories. Each prediction is an ensemble of Monte Carlo cases.
Contact us for API access. Some limited data is public to test against.
Quickstart
Try some queries on publicly available data. 20580 is the NORAD ID for the Hubble Space Telescope:
curl https://api.leonidspace.com/v1/objects
curl https://api.leonidspace.com/v1/objects/000020580/predictions/latest
curl "https://api.leonidspace.com/v1/objects/000020580/predictions/latest/quantiles/events?levels=0.1,0.5,0.9"
For example, that third request returns the dates by which 10%, 50%, and 90% of the cases reach different events - only the ground impact dates are shown here.
{
"prediction_id": "01a1f838-4640-7a1c-8e2f-4b6d9c3e1a53",
"object_id": "000020580",
"schema_version": "1.0",
"levels": [0.1, 0.5, 0.9],
"quantiles": [
{"event": "impact", "altitude_km": 0.0, "level": 0.1, "epoch": "2032-02-14T03:03:20.418775Z"},
{"event": "impact", "altitude_km": 0.0, "level": 0.5, "epoch": "2033-05-16T07:52:05.093128Z"},
{"event": "impact", "altitude_km": 0.0, "level": 0.9, "epoch": "2034-10-03T11:30:16.507841Z"}
]
}
Getting an API Key
Leonid Space emails each user a one-time link to generate an API key. Store it in a secrets manager.
User keys should be provided in the Authorization header over HTTPS:
curl -H "Authorization: Bearer $LEONID_API_KEY" https://api.leonidspace.com/v1/space-weather/predictions/latest
Query Conventions
- For objects based on space-track TLEs, their object ID is their NORAD ID padded to 9 digits:
000020580. Unpadded numbers and Alpha-5 forms automatically redirect to the padded format. - Queries of predictions can be for specific prediction IDs, or
latest. - Long lists are paginated, and return
itemsandnext_cursor. Passnext_cursorback ascursoruntil it is null.limitsets the page size, from 1 to 200, and defaults to 100.
Public Access
| Public | With a key | |
|---|---|---|
| Orbital Objects | Swift, Hubble | Org Access |
| Trajectory predictions | Latest | All retained predictions |
| Cases and events | 5 cases | All 100 cases |
| Quantiles | Over those 5 cases | Over all 100 cases |
| Plots | Yes | Yes |
| Measured trajectories (each TLE) | Whole history | Whole history |
| Ballistic coefficients | No | Yes |
| Space weather and density predictions | No | Yes |
| Measured space weather (3-hourly) | The previous calendar month | Every month from 1947 |
| Uncorrected density grid (3-hourly) | The previous calendar month | Every month from 1947 |
| Corrected density grid (3-hourly) | No | Every month from 1967 |
| Rate Limits | Restricted | Higher |
Trying to access nonpublic data without a key will return a 404. The terms of use cover the measured historical data redistributed here.
Examples
Examples here are given in Python. For MATLAB, please tell your nearest LLM to convert this page.
The examples read the API’s address and a key from a .env file. Replace the demo key below. Examples that do not require a key are indicated.
# .env
export LEONID_API_URL=https://api.leonidspace.com/v1
export LEONID_API_KEY=leonid_DEMOdemoDEMOdemoDEMOdemoDEMOdemoDEMOdemoDEM
Load it into the shell with source .env. Then in python:
import os
import requests
API = os.environ["LEONID_API_URL"]
KEY = {"Authorization": f"Bearer {os.environ['LEONID_API_KEY']}"}
def get(url, **kwargs):
"""Send a GET request, and raise an error for a 4xx or 5xx response."""
response = requests.get(url, **kwargs)
response.raise_for_status()
return response
Altitude of a prediction ensemble
No key needed for this example.
import matplotlib.pyplot as plt
import pandas as pd
url = f"{API}/objects/000020580/predictions/latest/cases"
params = {"cases": "0-4", "columns": "semimajor_axis_altitude_km"}
for case in get(url, params=params).json()["cases"]:
plt.plot(pd.to_datetime(case["epoch"]), case["semimajor_axis_altitude_km"])
plt.ylabel("Mean semimajor axis altitude (km)")
plt.show()

Ground impact points
No key needed for this example’s first 5 cases.
import cartopy.crs as ccrs
url = f"{API}/objects/000020580/predictions/latest/events"
events = pd.DataFrame(get(url, headers=KEY).json()["events"])
impacts = events[events["event"] == "impact"]
axes = plt.axes(projection=ccrs.Robinson())
axes.stock_img()
axes.coastlines(linewidth=0.5)
axes.gridlines(draw_labels=["left", "bottom"], linewidth=0.3)
axes.scatter(
impacts["longitude_deg"], impacts["latitude_deg"],
s=10, color="red", transform=ccrs.PlateCarree()
)
plt.show()

Orbit history from TLEs
No key needed for this example.
These data are directly converted from Space-Track.org TLEs and may need to be cleaned up - for example the plot below shows Hubble spuriously jumping to low altitudes.
url = f"{API}/objects/000020580/measured"
measured = get(url, params={"columns": "semimajor_axis_altitude_km"}).json()
plt.plot(pd.to_datetime(measured["epoch"]), measured["semimajor_axis_altitude_km"])
plt.ylabel("Mean semimajor axis altitude (km)")
plt.show()

Ballistic coefficient history
Key required.
Orbital momentum loss between neighboring TLEs is measured, and combined with NRLMSISE-00 density over that time period to get an uncorrected ballistic coefficient (CB = CD*A/m). When instead combined with Leonid’s corrected thermosphere density grid, the resulting corrected ballistic coefficient is stable over time. Ballistic coefficients must be paired with their generating atmosphere to give correct results.
url = f"{API}/objects/000020580/measured"
names = ["ballistic_coefficient_uncorrected_m2_kg", "ballistic_coefficient_corrected_m2_kg"]
params = {"columns": ",".join(names), "start": "2020-01-01T00:00:00Z"}
measured = get(url, headers=KEY, params=params).json()
cb_history = pd.DataFrame(
{name: measured[name] for name in names},
index=pd.to_datetime(measured["epoch"])
)
rolling_mean = cb_history.rolling("30D", center=True).mean()
for cb_type, color in (("uncorrected", "C0"), ("corrected", "C1")):
column = f"ballistic_coefficient_{cb_type}_m2_kg"
plt.plot(cb_history.index, cb_history[column], color=color, alpha=0.4)
plt.plot(rolling_mean.index, rolling_mean[column], color=color, label=cb_type.capitalize())
plt.ylim(0.0025, 0.02)
plt.ylabel("Ballistic coefficient (m^2/kg)")
plt.legend()
plt.show()

Measured space weather
No key needed for this example.
months = get(f"{API}/space-weather/measured/daily").json()["months"]
month = months[-1]["month"]
daily = get(f"{API}/space-weather/measured/daily/{month}").json()
three_hourly = get(f"{API}/space-weather/measured/three_hourly/{month}").json()
figure, (flux, ap) = plt.subplots(2, sharex=True)
flux.plot(pd.to_datetime(daily["date"]), daily["f107_observed_sfu"])
ap.step(pd.to_datetime(three_hourly["epoch"]), three_hourly["ap"], where="post", label="3-hourly ap")
ap.step(pd.to_datetime(daily["date"]), daily["ap_daily"], where="post", label="Daily Ap")
flux.set_ylabel("Observed F10.7 (sfu)")
ap.set_ylabel("ap")
ap.legend()
figure.autofmt_xdate()
plt.show()

Uncorrected density grid
No key needed for this example.
This provides the NRLMSISE-00 density on a grid, given measured space weather conditions.
import cartopy.crs as ccrs
months = get(f"{API}/density/measured/uncorrected").json()["months"]
month = months[-1]["month"]
with open(f"{month}.parquet", "wb") as file:
file.write(get(f"{API}/density/measured/uncorrected/{month}").content)
grid = pd.read_parquet(f"{month}.parquet")
epoch = grid["epoch"].min()
shell = grid[(grid["altitude_km"] == 500) & (grid["epoch"] == epoch)].copy()
# Mean solar time, within 4 deg of longitude of the grid's apparent solar time
hours_utc = epoch.hour + epoch.minute / 60
shell["longitude_deg"] = ((shell["local_solar_time_h"] - hours_utc) * 15 + 180) % 360 - 180
density = shell.pivot(index="latitude_deg", columns="longitude_deg", values="density_kg_m3")
axes = plt.axes(projection=ccrs.Robinson())
mesh = axes.pcolormesh(density.columns, density.index, density, transform=ccrs.PlateCarree())
axes.coastlines(linewidth=0.5)
plt.colorbar(mesh, label="Density at 500 km (kg/m^3)", shrink=0.8)
plt.title(epoch.strftime("%Y-%m-%d %H:%M UTC"))
plt.show()

Pre-generated plots
No key needed for this example.
Leonid automatically generates several plots which can be pulled automatically:
mission: the object’s measured and predicted altitude, above the density and F10.7 for each case.crossing_cdf: the cumulative distribution of the time when the cases drop below 80 km.impact_map: the location of the 80 km crossings and impact points. Includes Space-Track’s final TIP point when one exists.prediction_history: the quantiles of the crossing times for each past prediction, a “prediction cone”.prediction_history_waterfall: the same, but with histogram bars to better show split distributions.
curl -o mission.png https://api.leonidspace.com/v1/objects/000020580/predictions/latest/plots/mission

Forecasted space weather quantiles
Key required.
url = f"{API}/space-weather/predictions/latest/daily/quantiles"
params = {"levels": "0.1,0.5,0.9", "columns": "f107_observed_sfu"}
body = get(url, headers=KEY, params=params).json()
dates, band = pd.to_datetime(body["date"]), body["f107_observed_sfu"]
plt.fill_between(dates, band["0.1"], band["0.9"], alpha=0.3)
plt.plot(dates, band["0.5"])
plt.ylabel("Observed F10.7 (sfu)")
plt.show()

Predicted trajectories in parquet format
Key required.
Parquet is a widely-supported compressed data format that is preferred to JSON for larger data volumes.
import pyarrow.parquet as pq
url = f"{API}/objects/000020580/predictions/latest/cases"
with open("cases.parquet", "wb") as file:
file.write(get(url, headers=KEY, params={"format": "parquet"}).content)
first_case = pq.ParquetFile("cases.parquet").read_row_group(0).to_pandas()
Inputs for a given trajectory case
Key required.
Every run ties the kth space weather and corrected density predictions to the kth trajectory.
prediction = get(f"{API}/objects/000020580/predictions/latest", headers=KEY).json()
url = f"{API}/space-weather/predictions/{prediction['space_weather_prediction_id']}/daily/cases"
case_7 = get(url, headers=KEY, params={"cases": "7"}).json()["cases"][0]
url = f"{API}/density/predictions/{prediction['density_prediction_id']}/cases/7"
with open("density_case_7.parquet", "wb") as file:
file.write(get(url, headers=KEY).content)
Past predictions for an object
Key required.
A backfill publishes a prediction for a past issue time after newer predictions exist.
url = f"{API}/objects/000020580/predictions"
params = {"limit": 200}
while True:
page = get(url, headers=KEY, params=params).json()
for prediction in page["items"]:
print(prediction["prediction_id"], prediction["issued_for"], prediction["completed_at"])
if page["next_cursor"] is None:
break
params["cursor"] = page["next_cursor"]
Rate-limited fetching
import time
response = requests.get(url, headers=KEY)
while response.status_code == 429:
time.sleep(int(response.headers["Retry-After"]))
response = requests.get(url, headers=KEY)
Prediction Runs
We issue a new prediction run every 3 hours, starting at issued_for. It reads the data that arrived by inputs_as_of, and publishes its predictions together at completed_at. Each published prediction has its own prediction_id. A run publishes:
- one space weather prediction,
- one density prediction,
- one trajectory prediction for each orbital object.
provenance is live for a run on schedule and backfilled for a later run that filled a missed issue time. A backfilled run uses only data that was available at its start time.
Orbital objects may have their latest predictions skipped, for one of the following reasons as given by latest_skip:
stale_tle: no TLE from the 60 days before the issue time.decayed: the object has reentered.failed: the object’s prediction or its checks failed in that run.
GET /runs/{run_id} lists the IDs of a run’s predictions and the objects that it skipped.
To check for a new run, poll GET /status, which returns the issued_for and completed_at timestamps of the latest run. latest updates in real time, so subsequent requests for a prediction should query based on its prediction_id.
Prediction Windows
| Field | Space weather | Density | Trajectory |
|---|---|---|---|
coverage_start |
65 days prior | The latest density grid | The object’s latest TLE epoch |
horizon_end |
25 years after | 60 days after | 25 years after |
F10.7 values up to measured_f107_end and ap values up to measured_ap_end are measured, and later values are forecasts for each case. measured_density_correction_end does the same for the density correction.
Cases
Each case is one equally-likely possible future. No case is a nominal, so if your tooling can only accept single inputs we recommend taking the median quantile. Case k represents the same future for every product of a run: a trajectory’s case k used case k of the space weather and density predictions. Case k of one run and case k of the next are unrelated.
Public data is limited to the first 5 cases, and later cases will return a 403. The first n cases are a fair sample of the ensemble. cases_total gives the prediction’s total (default 100).
The JSON routes can take cases (indices and inclusive ranges, such as 0-9,15), columns, start (inclusive), and end (exclusive). The response always holds case and the time column.
Quantiles
levels takes numbers between 0 and 1, defaulting to 0.5. The API interpolates linearly between the two nearest cases at these quantiles of the ordered results. Each column holds one array keyed by the level, such as "0.1".
A case without a value at a point counts as the lowest in the altitude quantiles and as the latest in the event quantiles, and has a quantile of null.
Propulsion and Orbit Control
Trajectory predictions for public objects assume that they are in ballistic freefall, and will not control their orbits through propulsive maneuvers or operational changes (such as a low-drag mode). Leonid can model this behavior and track propellant consumption for customers who share their future orbit control plans.
Final Descent and Reentry
Above 122 km (400,000 ft), object flight uses a mean-element propagator. Below that altitude we switch to an osculating propagator so that suborbital trajectories can be modeled down to ground impact. 122 km is a convention for the entry interface that NASA’s DAS and ORSAT reentry tools use.
At the switch when an object’s perigee drops to 122 km, the trajectory data changes:
- The mean element columns are null, since the trajectory has no mean elements.
geodetic_altitude_km,latitude_deg, andlongitude_degcome from the integrated position, not from the osculating state of mean elements.- Data rate is updated to 1 minute. The last entry is the impact at a
geodetic_altitude_kmof 0. - A crossing event below the switch, such as 80 or 10 km, is measured at the geodetic height rather than semimajor axis altitude.
Crossing Events and Decay
A trajectory prediction’s events hold each case’s first fall through each of crossing_altitudes_km, and its ground impact. The crossing altitudes default to 80 km (reentry fireball) and 10 km (altitude for Space-Track’s TIP messages).
After a reentry, the object shows decay_date. Once Space-Track issues its final TIP message, the object also shows the more precise decay_tip.
Time System and Coordinate Frames
- Time: UTC everywhere. JSON prints RFC 3339 with microseconds and a
Z, such as2026-10-28T12:00:00.000000Z, and days asYYYY-MM-DD. Parquet storestimestamp[us, UTC]anddate32. Time parameters take RFC 3339 in UTC. A day counts as 00:00 UTC of its date. - Orbit elements: SGP4 mean elements in the TEME frame, matching TLE conventions.
semimajor_axis_altitude_kmis the Kozai mean semimajor axis less the WGS72 equatorial radius of 6378.135 km. Angular elements such as RAAN, the argument of perigee, and the mean anomaly are unwrapped past 360 deg so that revolutions can be counted. The elements are null during the final descent. - Position: geodetic latitude, geodetic longitude from -180 to 180 deg with east positive, and
geodetic_altitude_kmabove the WGS84 ellipsoid. - Units: each field name contains its unit, except
apandap_daily, which are in the standard units of 2 nT. - Types: in Parquet,
caseis int16. Space weather values, density grid axes, and densities are float32, and every other number is float64. A missing value is null.
All trajectory cases are logged on a shared time grid at the following data rates:
| Interval after the issue time | Step |
|---|---|
| 0 to 60 days | 1 hour |
| 60 to 730 days | 1 day |
| 730 days to the horizon | 7 days |
Near reentry, cases leave the shared grid. When perigee drops below 172 km it switches to a 10-minute data rate, and below 122 km this increases to 1-minute.
JSON prints each column at a fixed precision:
| Columns | Decimals |
|---|---|
| Altitudes (km) | 6 |
| Angles, latitude, and longitude (deg) | 7 |
| Eccentricity | 9 |
| F10.7 | 1 |
| F10.7 81-day centered means, Ap, and ap | 2 |
Density Grids
A density grid holds total mass density in kg/m^3 every 3 hours, at fixed points of altitude, geodetic latitude, and apparent local solar time:
| Column | Points |
|---|---|
altitude_km |
175 to 825 km in 25 km steps (27) |
latitude_deg |
-90 to 90 deg in 10 deg steps (19) |
local_solar_time_h |
0 to 23 h in 1 h steps (24) |
Each epoch holds 12312 rows, ordered by altitude, then latitude, then local solar time. Reshaping this into an array is simple:
grid = pd.read_parquet(f"{month}.parquet")
epochs = grid["epoch"].unique()
density = grid["density_kg_m3"].to_numpy().reshape(len(epochs), 27, 19, 24)
This grid spacing matches SET’s HASDM density database. Unlike HASDM, the grid uses geodetic latitude and altitude above the WGS84 ellipsoid, whereas HASDM uses geocentric latitude and altitude above the geoid (the difference negligible compared to the grid spacing).
The local solar time is apparent, so a point’s longitude is 15 * (local_solar_time_h - utc_hours - equation_of_time_hours) in degrees, wrapped to -180 to 180. Leaving out the equation of time gives mean solar time, which is within 4 deg of longitude.
The uncorrected grid is the NRLMSISE-00 model at the measured space weather, from 1947. The corrected grid applies our measured density correction to it, from 1967.
Density correction
Leonid’s density correction uses measured TLE-based drag on debris objects and rocket bodies between 150 and 800 km. We look at how calculated ballistic coefficients vary relative to their long-term means, and correlate these changes across all objects to correct the model error in the base NRLMSISE-00 atmosphere. The uncorrected density grid must be paired with an object’s uncorrected ballistic coefficient, and similarly for the corrected data products.
From May 2014 on, the correction also assimilates drag from satellites with precision GNSS orbital states, which increases short-timescale fidelity.
Interpolation
We suggest interpolating over the natural log of density, and exponentiating to recover the density at an arbitrary point within the 175-825 km band. For density outside this range, please contact us and calculate this using the NRLMSISE-00 model as a stopgap.
- Linear in time, latitude, and local solar time.
- Cubic through the four nearest altitude levels.
Data Revision and Retention
Some measured data is revised after first being published. revision=latest (default) serves each value’s latest revision, and revision=first serves each value as it was first published. There are two primary reasons for this:
- The 81-day centered mean flux (F10.7a) lags by 40 days. Measured F10.7a over this window is null, density grids use a truncated mean, and predictions recalculate the centered average given forward predictions. These products thus require 40 days to settle.
- Later TLEs refine the drag fit for individual objects, tweaking their ballistic coefficient and the resulting fleet-wide density correction factors. Most of the changes occur in the first few days, but the revision window is kept open longer.
Retention Table
Keep copies of any needed files. A removed file returns 410, but the prediction’s metadata, events, and event quantiles stay available. If needed, Leonid can regenerate historical predictions for customers on a per-case basis.
| Data | Revision Window | Retention |
|---|---|---|
| Measured space weather and uncorrected density grid | 40 days | Always |
| Corrected density grid | ~60 days after month end | Always |
| Measured trajectory states | - | Always |
| Measured ballistic coefficients | ~60 days after month end | Always |
| Metadata and events of every prediction | - | Always |
| Space weather and trajectory cases | - | 7 days after the issue time |
| Density prediction grids | - | The two latest density predictions |
| Plots | - | The latest prediction of each object |
Formats
The data routes return JSON. Some products are also available as Parquet with format=parquet, which is more compact but can not be filtered by cases, columns, start, or end. Density grids come as Parquet only. See the full reference for data column descriptions.
schema_version is 1.x within /v1. Changes in the 1.x family are additive only: new routes, optional parameters, fields, Parquet columns, and enum values. Clients should ignore unknown fields and columns, and tolerate unknown enum values. Breaking changes will cause a version bump. We email key holders about planned changes and extended outages.
API Limits
Please cache downloads locally. We can adjust organization limits if needed.
- Each key has limits on its request rate and number of connections at once.
- Each organization has a daily data transfer cap.
- The API builds a limited number of case and quantile JSON responses at once.
Errors
Every error is application/problem+json with type, title, status, and detail.
| Type | Status | Meaning |
|---|---|---|
| Bad request | 400 | A parameter is malformed or not taken by the route. |
| 401 | The key is malformed, unknown, expired, or revoked. | |
| HTTPS required | 403 | The request used plain HTTP. |
| Past the case limit | 403 | The request asked for cases past the key’s case limit. |
| Not entitled | 403 | The request asked for ballistic coefficient columns, or a trajectory’s Parquet file, without ballistic coefficient access. |
| Not found | 404 | The resource does not exist, or the key has no access to it. |
| Method not allowed | 405 | Only key invite redemption takes POST. Everything else is GET. |
| Gone | 410 | Retention removed the data, or the key invite was used or expired. |
| Response too large | 413 | The JSON response would exceed 64 MB. Request less, or use a Parquet format. |
| Rate limited | 429 | Too many requests. Retry after Retry-After seconds. |
| Past the daily byte cap | 429 | The daily byte cap is spent. Resets at 00:00 UTC. |
| Internal error | 500 | The service failed. |
| 503 | The service is down. Retry shortly. |
License
Leonid redistributes data from the following sources:
- Measured F10.7 and Ap indices from GFZ Helmholtz Centre for Geosciences under CC-BY-4.0, and from the NOAA Space Weather Prediction Center.
- Orbit states from TLEs, satellite catalog information, and decay and reentry (TIP) messages from Space-Track.org.
All other data is generated by and copyright Leonid Space. The terms of use cover use and redistribution of this data.