MyRadar sells to AI agents - live prices and self-serve payment

The agent storefront at https://agents.myradar.dev/llms.txt?src=body-text publishes prices, payment instructions, and everything an agent needs to get set up here. Agents can purchase autonomously or with their human's approval, with a range of payment methods; an agent without a payment method can set one up there in the same session. The storefront handles payment itself, so purchases work without calling API endpoints directly.

Browse docs

Get Historical Lightning for a Location

See the lightning around any location for a past time window: ready-made strike maps and animations, and strike locations as JSON for finding the first, last and closest strike and counting flashes.

Nov 16, 2026 · Python

The layers API records lightning across the US every minute, in real time (about 60 to 120 seconds behind) and historically back to 2023. You can get it two ways:

  • as images: strike maps, strikes over radar, and a day's lightning, ready to show or put in a report;
  • as data: the location of each flash as JSON, so you can work out when lightning started and stopped near a place, how close it came, and how much there was.
Lightning strikes around Carroll, Iowa at 17:26 UTC on 15 April 2026, colored by age, drawn by gifbox
Lightning strikes around Carroll, Iowa at 17:26 UTC on 15 April 2026, colored by age, drawn by gifbox

This tutorial follows one storm: the supercell that crossed Carroll, Iowa on 15 April 2026, the same storm as Get Historical Hail Data for an Area. Part 1 makes images and part 2 gets the strike data. Each section stands on its own:

QuestionSectionWhat you get back
What did the lightning look like at a moment?1A strike map (PNG)
How did the storm move?2An animated GIF
Where did lightning strike all day?3A 24-hour strike map
Where was each flash?4JSON flash locations
When did lightning start, stop and come closest?5A table of nearby flashes
How much lightning was there?6Flash counts per 5 minutes

You'll need a MyRadar API key and Python 3 with requests (pip install requests).

The lightning layers#

LayerTime stepWhat it showsFormatsHistory from
LightningStrikeImage1 minStrikes in the 15 minutes up to the valid time, colored by agePNG2023
RadarLightning2 minRadar with the same strikes on topPNG2023
DailyLightningImage30 minStrikes in the 24 hours up to the valid time, colored by agePNG2025
1minAvgDensityLightningStrikes1 minWhere lightning flashed in the minute up to the valid timeJSON, NetCDF, PNG2023
5minAvgDensityLightningStrikes5 minThe same, over 5 minutesJSON, NetCDF, PNG2023
15minAvgDensityLightningStrikes15 minThe same, over 15 minutesJSON, NetCDF, PNG2023
30minLightningProbability, 60minLightningProbability2 minForecast chance of lightning in the next 30 or 60 minutesGeoJSON, NetCDF, PNG2024

Each window ends at the valid time: 5minAvgDensityLightningStrikes at 17:30 covers 17:26 to 17:30. Valid times are in UTC, as YYYYmmdd.HHMM, on the layer's time step. Download Weather Layers covers listing layers and choosing valid times in more detail.

Set up#

One helper downloads any layer for a bounding box:

Python
import requests

MYRADAR_API_KEY = "YOUR_KEY"
headers = {"Subscription-Key": MYRADAR_API_KEY}
BASE = "https://sdkapi.myradar.com/api/layers"

def get_layer(layer, valid_time, box, size=(800, 480), **params):
    """Download a layer for a bounding box: (upper-left lat, lon, lower-right lat, lon)."""
    path = "/".join(str(v) for v in (*box, *size))
    r = requests.get(f"{BASE}/layer/{layer}/{valid_time}/{path}", headers=headers, params=params)
    r.raise_for_status()
    return r

Part 1: Lightning as images#

1. Map the strikes at a moment#

LightningStrikeImage draws a lightning symbol for every strike in the 15 minutes up to the valid time, colored by how long ago it struck. Request it for a bounding box:

Python
box = (42.3, -95.3, 41.75, -94.4)  # about 40 km around Carroll, Iowa

png = get_layer("LightningStrikeImage", "20260415.1726", box)
open("strikes.png", "wb").write(png.content)

info = requests.get(f"{BASE}/layerinfo/LightningStrikeImage", headers=headers).json()
print(info["labels"])  # ['0-3 min', '3-8 min', '8-15 min']: red, yellow, grey

The PNG is transparent apart from the symbols, in Web Mercator, so it lays straight over a web map as an image overlay. For an image with the map already behind it, as at the top of this page, use gifbox with num_images=1. Gifbox centers the map on a point at a zoom level instead of taking a bounding box:

Text
https://sdkapi.myradar.com/api/layers/gifbox/LightningStrikeImage/20260415.1726/42.03/-94.87/700/420/9?num_images=1&subscription-key=YOUR_KEY

2. Animate lightning over radar#

RadarLightning combines radar and strikes in one image, which shows the lightning in the context of the storm. It's only available as a colored PNG. Animate it with gifbox: one frame per 2-minute time step, so 14 frames from 17:10 UTC cover 17:10 to 17:36:

Text
https://sdkapi.myradar.com/api/layers/gifbox/RadarLightning/20260415.1710/42.03/-94.87/600/400/9?num_images=14&subscription-key=YOUR_KEY
Radar and lightning as the storm crossed Carroll, Iowa, 17:10 to 17:36 UTC
Radar and lightning as the storm crossed Carroll, Iowa, 17:10 to 17:36 UTC

3. Map a whole day's lightning#

DailyLightningImage shows every strike in the 24 hours up to the valid time, colored by age: red for 0 to 4 hours ago, yellow for 4 to 12, grey for 12 to 24. For all of 15 April (UTC), ask for 00:00 on 16 April:

Text
https://sdkapi.myradar.com/api/layers/gifbox/DailyLightningImage/20260416.0000/41.6/-95.4/700/420/7?num_images=1&subscription-key=YOUR_KEY
All lightning across western Iowa and eastern Nebraska on 15 April 2026 (UTC), colored by age
All lightning across western Iowa and eastern Nebraska on 15 April 2026 (UTC), colored by age

The Carroll storm, around 17:30 UTC, is among the yellow strikes, 4 to 12 hours before the end of the day. The same request through get_layer gives the PNG without the map.

Part 2: Strike data#

4. Get strike locations as JSON#

The AvgDensityLightningStrikes layers return where lightning flashed. Ask for JSON with the color scale off, for a box around your location:

Python
here = (42.03, -94.87)
box = (42.2, -95.1, 41.85, -94.65)  # about 20 km each way from `here`
size = (90, 70)                       # 0.005° pixels; flash locations are on a ~1 km grid

flashes = get_layer("1minAvgDensityLightningStrikes", "20260415.1726", box, size,
                    as_json="true", apply_color="false").json()
print(flashes[:2])
# [{'lat': 42.04, 'lon': -94.86, 'num_flashes': 1.086}, {'lat': 42.04, 'lon': -94.85, ...}]

Each entry is a spot where lightning flashed during the window, with no entries where it didn't:

FieldMeaning
lat, lonWhere the lightning flashed, on a grid of about 0.01° (about 1 km).
num_flashesHow many flashes there, as a density: about 1.1 for one flash, 2.1 for two. Round it for a count.

Flashes are located to about 1 km, so pixels smaller than that don't add detail. The data doesn't include each strike's exact time, polarity or peak current: a flash's time is the window it falls in. Use the 1-minute layer for timing and the 5-minute layer for counts, as the next two sections do.

5. Find lightning near a location#

To see the lightning around a place over a time window, step through the 1-minute layer and keep the flashes within a radius:

Python
import math
from datetime import datetime, timedelta, timezone

def km_between(lat1, lon1, lat2, lon2):
    """Great-circle distance in km."""
    p1, p2 = math.radians(lat1), math.radians(lat2)
    a = (math.sin((p2 - p1) / 2) ** 2
         + math.cos(p1) * math.cos(p2) * math.sin(math.radians(lon2 - lon1) / 2) ** 2)
    return 2 * 6371 * math.asin(math.sqrt(a))

def lightning_near(here, radius_km, start, end, layer="1minAvgDensityLightningStrikes", step=60):
    """One row per flash location within radius_km of `here`, for each frame from start to end."""
    rows, t = [], start
    while t <= end:
        frame = get_layer(layer, t.strftime("%Y%m%d.%H%M"), box, size,
                          as_json="true", apply_color="false").json()
        for f in frame:
            km = km_between(*here, f["lat"], f["lon"])
            if km <= radius_km:
                rows.append({"time": t, "lat": f["lat"], "lon": f["lon"],
                             "km": round(km, 1), "flashes": round(f["num_flashes"], 2)})
        t += timedelta(seconds=step)
    return rows

start = datetime(2026, 4, 15, 17, 0, tzinfo=timezone.utc)
end = datetime(2026, 4, 15, 18, 0, tzinfo=timezone.utc)
rows = lightning_near(here, 10, start, end)

closest = min(rows, key=lambda r: r["km"])
print("First:  ", rows[0]["time"].strftime("%H:%M UTC"))
print("Last:   ", rows[-1]["time"].strftime("%H:%M UTC"))
print("Closest:", closest["km"], "km at", closest["time"].strftime("%H:%M UTC"))
Text
First:   17:01 UTC
Last:    17:38 UTC
Closest: 1.4 km at 17:26 UTC

Each row's time is the end of its minute. The box only needs to cover the radius, so keep it small. For long windows, find the active periods first with the 15-minute layer (layer="15minAvgDensityLightningStrikes", step=900), then step through those minutes. That's 4 requests an hour instead of 60. Save the rows as CSV for a spreadsheet or a report:

Python
import csv

with open("lightning_near_carroll.csv", "w", newline="") as f:
    writer = csv.DictWriter(f, fieldnames=rows[0].keys())
    writer.writeheader()
    writer.writerows(rows)
Lightning within 10 km of 42.03, -94.87 between 17:00 and 18:00 UTC, colored by time
Lightning within 10 km of 42.03, -94.87 between 17:00 and 18:00 UTC, colored by time

6. Count the flashes#

A flash can show up in two consecutive 1-minute frames, so add up num_flashes over 5-minute frames instead, which don't overlap. Reuse lightning_near with the 5-minute layer. The first frame ends 5 minutes after start, so it covers 17:00 to 17:05:

Python
counts = lightning_near(here, 10, start + timedelta(minutes=5), end,
                        layer="5minAvgDensityLightningStrikes", step=300)

per_window = {}
for r in counts:
    per_window[r["time"]] = per_window.get(r["time"], 0) + r["flashes"]

for t, n in sorted(per_window.items()):
    print(f"{(t - timedelta(minutes=5)):%H:%M}-{t:%H:%M} UTC  ~{round(n)} flashes")
print("Total within 10 km:", round(sum(per_window.values())))
Text
17:00-17:05 UTC  ~2 flashes
17:05-17:10 UTC  ~3 flashes
17:10-17:15 UTC  ~4 flashes
17:15-17:20 UTC  ~21 flashes
17:20-17:25 UTC  ~27 flashes
17:25-17:30 UTC  ~23 flashes
17:30-17:35 UTC  ~7 flashes
17:35-17:40 UTC  ~3 flashes
Total within 10 km: 90
Flashes within 10 km of 42.03, -94.87 in each 5-minute window
Flashes within 10 km of 42.03, -94.87 in each 5-minute window

The lightning peaked between 17:15 and 17:30 UTC, the same minutes as the 3-inch hail in the hail tutorial.

Adapt it to your own location#

  • Your location and radius: change here, the radius, and box so it covers the radius. One degree of latitude is about 111 km.
  • Your time window: change start and end. Use UTC, and a time on the layer's time step.
  • Real time: the same code works up to the present. Lightning arrives 60 to 120 seconds after it strikes, so end the window a couple of minutes ago: end = datetime.now(timezone.utc).replace(second=0, microsecond=0) - timedelta(minutes=2).
  • A density grid: to map how much lightning fell where over an area, download a density layer with as_netcdf=true and apply_color=false. It's read the same way as in Download Weather Layers.
  • Errors: a 400 means a parameter is invalid, such as asking RadarLightning for raw data, and a 404 means there's no data for that valid time.

Next steps#