This is a service for receiving notifications about lightning strikes. It pushes out messages to the clients as soon a lightning strikes unlike a pull service where the client periodically asks the server if anything has happened. This will enable the clients to get notified as soon as possible. There will however always be some delay while the the data flows thru the system.
This service can only be used by authorized clients and usage is bound to a charge. To get an authorization key please contact SMHI Customer Service. Use the key when connecting your client to the service.
Only one client per authorization key can connect at a time. If you try to connect two clients with the same key the first one will be disconnected when the second one connects. If your client for some reason gets disconnected, then you should reconnect it again to receive further messages. A heartbeat message is sent every 30 second. Use this in combination with a timer to know when you need to reconnect.
The clients workflow consists of the following steps:
- Connect to the service at ws://data-push.smhi.se/api/category/lightning-strike/version/1/country-code/SE/data.json
- Authorize the client. This is done with basic authentication.
- Receive messages. The following two types of messages exist.
ZZthen this is a heartbeat message. Only
countryCodei valid. Use these messages to know if the connection is alive. If not, then you need to reconnect. There should be a heartbeat message every 30 second.
SEthen there has been a lightning recorded and all attributes are valid.
The formats used by the WebSocket for lightning strikes looks like this:
|time||String||Date and time for when the lightning struck in UTC. Format: "[yyyy]-[dd]-[mm]T[hh]:[mm]:[ss].[mmm]Z" ISO 8601|
|countryCode||String||Short code for the country. The only valid value today is "SE" ISO 3166|
|lat||Number||Latitude of the lightning struck in signed degree format. Format: [DDD].[dddd]|
|lon||Number||Longitude of the lightning struck in signed degree format. Format: [DDD].[dddd]|
|proj||String||Projection used for latitude and longitude. The only valid value today is "EPSG:4326" EPSG:4326|
|peakCurrent||Number||The electric current of the lightning in signed integer format. The unit is kilo Ampere (kA)|
|cloudIndicator||Number||Indicates if the lightning was in cloud or cloud to ground.
Valid values are
SMHI Open Data API is published under these Terms and conditions.