# Merge lightning history with the live feed

> Load recent strikes from the REST route, then carry on from your MQTT feed without drawing any flash twice.

Developers · How-to guide · https://wxalerts.org/docs/developers/mqtt/merging-lightning/

Your [MQTT lightning feed](/docs/developers/mqtt/lightning/) keeps nothing and
replays nothing, so a client that has just connected has no strikes from before
it did. [`GET /lightning/flashes`](/docs/api/lightning/) reads the last hours
back. The time to the millisecond and the position to four decimals identify a
flash in both, so one heard live and the same one read from the route match
exactly.

1. Start your MQTT client and subscribe first, so nothing falls in the gap.
2. Load the history from the REST route for the box you care about.
3. Key a set on `t_ms,lat,lon` (for a live strike, `t` as epoch milliseconds
   with its `lat` and `lon`) and put every historical flash in it.
4. For each live strike, skip it if its key is already in the set, and add it if
   not.
5. Fade flashes on `t_ms`, not on when you received them.
