{"openapi":"3.0.2","info":{"title":"DTN Lightning Stream API","version":"1.0.0","description":"# Introduction\nWelcome to the DTN Lightning Stream API - your streaming access to current lightning strike data . DTN’s fast, robust, and scalable Lightning Stream API has been designed to cater to a wide range of users, including:\n- Scientists engaged in climate research\n- Construction engineers and researchers\n- Energy company analysts\n- Software developers building weather apps\n\n**Key features**: DTN Lightning Stream API gives access to current lightning strike data, we collect data from several industry leading sources and provide you with the best suited source for your selected location or region. Measurements of strike magnitude and several parameters on error and accuracy are available for every strike.\nLike other DTN API’s, your response comes in a neatly packaged format which is easily parsable using any GeoJSON parser. The interactive documentation that follows is a guide to setting up requests, understanding responses, and leveraging all the features of DTN’s Lightning Stream API.\n\n# Transport & Architecture Notes\n This API uses *Socket.IO* instead of the native WebSocket protocol due to several key advantages:\n\n- **Security**: Native WebSocket protocols typically pass authentication tokens in the query string, which is easily exposed via browser history, logs, or proxy tools. Socket.IO, by contrast, transmits tokens via secure headers during the initial HTTP handshake.\n- **Automatic Reconnection**: Socket.IO provides built-in reconnection logic with exponential backoff, reducing client complexity and improving fault tolerance.\n- **Heartbeat / Ping-Pong Mechanism**: Socket.IO includes automatic heartbeat checks to detect broken connections and stale clients, ensuring reliable bidirectional communication.\n\nYou may connect via HTTPS (with automatic WebSocket upgrade) or directly over secure WebSocket (WSS) using the same path.\n\n**Note:** Due to SwaggerHub constraints, the `servers` list below only shows the `https://` variant. However, direct `wss://` connections are equally supported. \n\n # Getting Started\n## Prerequisites\nTo start using the DTN Lightning API, you don't need to be a programming wiz. Don't sweat the details; our easy-to-follow and interactive docs will have you pulling lightning observations in no time.\n\n## API Credentials\nTo start making requests, you will first need your API credentials that include your client ID and client secret. If you do not have your API credentials, please contact your account manager or the DTN sales team using this form.\n\nRemember not to share your API credentials publicly or use others' API keys, as this may compromise the security of your data.\n\nAfter you have obtained your API credentials, head over to the authentication section of this documentation to learn how to get your access token.\n\n## Making Your First Request\nStarting off your journey with the DTN Lightning API couldn't be easier. We've provided a variety of options to suit your needs and comfort level:\n\n**a) Interactive Documentation:** Our interactive documentation is a great starting point. Simply navigate to the \"Authentication\" section, insert your credentials, and you'll obtain an access token behind the scenes. Then, you can immediately start exploring the API endpoints right from within the documentation.\n\n**b) Writing Code:** If you're ready to dive into writing code, check out the examples below, which is requesting to stream lightning data from the time of the command execution:\n\n**Request for token:**\n```\n import requests\n import json\n\n #--- Obtain an API access token ---\n\n auth_url = 'https://identity.auth.dtn.com/v1/tokens/authorize'\n\n body = {\n 'grant_type': 'client_credentials',\n 'client_id': '...insert your client id here...',\n 'client_secret': '...insert your client secret here...',\n 'audience': 'wss://lightning.api.dtn.com'\n }\n response = requests.post(auth_url, json=body)\n print(response.json()['data']['access_token'])\n```\n\n**Invoke the Stream API:**\n```\nconst io = require('socket.io-client')\nconst socket = io(\"wss://lightning.api.dtn.com/v1\", {\n auth: { token: \"\" },\n transports: [\"websocket\"]\n})\n\nsocket.on(\"message\", (data) => {\n const parsedData = JSON.parse(data);\n console.log(\"Received data:\", JSON.stringify(parsedData, null, 2));\n});\n\nsocket.on('error', (error) => {\n console.error('Error:', error)\n})\n```\n\nIn this example, replace 'your_token_here' with the token you printed via the authorization endpoint. This will start the stream on the Stream API endpoint, and the response will be printed in your console."},"servers":[{"url":"https://lightning.api.dtn.com"}],"paths":{"/v1/":{"summary":"Used to retrieve strikes based upon specific parameters on a stream delivery.","description":"- Can be used to retrieve lightning strikes by either:\n - bounding box\n - radius\n- Additional time-based filtering can be done using `startTime` - The default for time filters is the time of execution of the request.","get":{"tags":["API Endpoints"],"summary":"Stream","description":"```\n https://lightning.api.dtn.com/v1/\n```\n\n This endpoint allows users to retrieve all lightning strikes, in a streaming manner, that match the set criteria.\n\n - Space: Observations can be searched geographically by:\n - `radius` required parameters: `lat`, `lon` and `radius`\n - `boundingBox` required parameters: `minLat`, `minLon`, `maxLat` and `maxLon`\n - Time: To stream starting on a specified time:\n - For start time, provide `startTime` value. \n - Data on the stream only last for `1 day`, any dates further can be retrieved from our other Lightning API.","security":[{"clientCredentials":[]}],"parameters":[{"name":"startTime","in":"query","schema":{"type":"string"},"description":"Get observations starting a specific time","required":false},{"name":"by","in":"query","schema":{"type":"string"},"description":"Get observations by radius | boundingBox.","required":false},{"name":"radius","in":"query","schema":{"type":"number","minimum":0,"maximum":100},"description":"Radius for radial search in km.","required":false},{"name":"lon","in":"query","schema":{"type":"number"},"description":"Longitude for radial search in decimal degrees, e.g. `54.85`.","required":false},{"name":"lat","in":"query","schema":{"type":"number"},"description":"Latitude for radial search in decimal degrees, e.g. `54.85`.","required":false},{"name":"minLon","in":"query","schema":{"type":"string"},"description":"Minimum longitude for boundingBox search in decimal degrees, e.g. `-1.85`","required":false},{"name":"minLat","in":"query","schema":{"type":"string"},"description":"Minimum latitude for boundingBox search in decimal degrees, e.g. `50.85`","required":false},{"name":"maxLon","in":"query","schema":{"type":"string"},"description":"Maximum longitude for boundingBox search in decimal degrees, e.g. `0.85`","required":false},{"name":"maxLat","in":"query","schema":{"type":"string"},"description":"Maximum latitude for boundingBox search in decimal degrees, e.g. `54.85`","required":false}],"responses":{"Success":{"$ref":"#/components/responses/GetStrikesDefault"},"Parameter Error":{"$ref":"#/components/responses/StrikeValidationError"},"Server Error":{"description":"Internal server error."}}}}},"tags":[{"name":"API Endpoints"}],"components":{"schemas":{"StrikesDefault":{"title":"Strikes","description":"Success","type":"object","properties":{"type":{"type":"string","enum":["Feature"],"default":"Feature"},"geometry":{"type":"object","properties":{"type":{"type":"string","enum":["Point"],"default":"Point"},"coordinates":{"coordinates":null,"type":"array","items":{"type":"number"},"minItems":2,"maxItems":2,"example":[-78.1907424927,31.2004070282],"description":"Strike coordinates (lon, lat)"}}},"properties":{"type":"object","example":{"timestamp":"2024-10-01T06:42:46.263Z","errorEllipseBearing":95.7,"errorEllipseSemiMajor":3600,"errorEllipseSemiMinor":400,"lightningType":"cloudToCloud","cloudToCloudHeight":1,"peakCurrent":8,"sensorCount":5}}}},"StrikeValidationError":{"title":"Validation Error Parameters Endpoint parameters","type":"string","example":" sent invalid parameter values. "},"Error":{"title":"Root Type for Error","description":"Error","required":["code","description","status"],"type":"object","properties":{"status":{"enum":["error"],"type":"string"},"code":{"enum":["invalid-id","internal-error","invalid-token","missing-scope"],"type":"string"},"description":{"type":"string"}},"example":{"status":"error","code":"invalid-token","description":"The token has expired."}}},"responses":{"GetStrikesDefault":{"description":"Lightning Strikes","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StrikesDefault"}}}},"StrikeValidationError":{"description":"Validation Error for Strike Endpoint Parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StrikeValidationError"}}}},"ErrorResponse":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"Error":{"value":{"status":"error","code":"invalid-token","description":"bad token"}}}}},"description":"info about error"},"HealthCheckReport":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthCheck"},"examples":{"Success":{"value":{"status":"up","version":"v2","info":"Service is healthy.","timestamp":"2018-02-10T09:30Z","env":"unknown"}}}}},"description":"Health Check report"}},"securitySchemes":{"clientCredentials":{"type":"oauth2","x-receive-token-in":"request-body","flows":{"clientCredentials":{"tokenUrl":"https://api.auth.dtn.com/v1/tokens/authorize"}},"description":"# Using DAIS for M2M/API Auth\nYou have been given a Client ID and a Client Secret, which are used to request a DTN Access Token. DTN Access Tokens are required when making calls to each and every DTN API endpoint. The following information provides additional details on these tokens and how they are generated.\n## What is an Access Token and how is it different from an API Key?\nAn API Key is a random string of characters that an API uses to authorize whether or not a calling client has approved access to an endpoint. These keys are a non-standard approach to API authorization and are generally issued on a per-API basis.\n\nAn Access Token is also a string of characters but is a base-64 encoded JavaScript Object Notation Web Token, or JWT. JWTs are a widely accepted standard that use OAuth concepts and approaches. \n\nBoth API Keys and Access Tokens are used in an Authorization Request Header as a Bearer, meaning there is no difference in where you put this string of characters when you make calls to DTN APIs.\n## How to generate an Access Token?\nWhen requested, an Access Token is generated for your specific Client (ID/Secret) and for a specific API. The DTN Auth and Identity Service (DAIS) generates new Access Tokens for your client. The DAIS endpoint is `POST https://api.auth.dtn.com/v1/tokens/authorize`.\n\nThis endpoint takes two Header parameters:\n * `Content-Type: application/json`\n * `Accept: application/json`\n\nThis endpoint takes four parameters in the Request Body:\n * `grant_type`: this should always be client_credentials for generating machine-to-machine tokens.\n * `client_id`: this is the Client ID or Application ID using the token and is given to you by DTN's Identity Team. This ID will never change for your client/application.\n * `client_secret`: this is the Client Secret that is associated with the Application ID and is given to you by DTN's Identity Team. This key is subject to rotation for security purposes but always with the client's knowledge.\n * `audience`: this is the API for which this Access Token will be used. For the DTN Lightning WebSocket, you need to use the following audience: https://lightning.api.dtn.com\n\nYou can use this CURL command template as a reference for obtaining an access token:\n ```\n curl --location --request POST 'https://api.auth.dtn.com/v1/tokens/authorize' \\\n--header 'Accept: application/json' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n\"grant_type\": \"client_credentials\",\n\"client_id\": \"insert your client id here\",\n\"client_secret\": \"insert your client secret here\",\n\"audience\": \"insert your audience here\"\n}' \n ```\n\n*This document, for demonstration purposes, supplies a client_id and client_secret in all code examples. This client/application is for a fictitious API and cannot be used in practice to gain unauthorized access to any other DTN API.*\nUpon generating a new Access Token, you should receive an HTTP Response from DAIS similar to this:\n ```\n {\n \"data\": {\n \"access_token\": \"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6InpfX21pZW13NGhoTmdvQWQxR3N6ciJ9.eyJodHRwczovL2F1dGguZHRuLmNvbS9jdXN0b21lcklkIjoiMTIzNDU2Nzg5MERlbW8iLCJodHRwczovL2F1dGguZHRuLmNvbS9wcm9kdWN0Q29kZSI6IkRlbW9BcGlQIiwiaHR0cHM6Ly9hdXRoLmR0bi5jb20vcmVxdWVzdGVySXAiOiIxOC4yMTMuMTc0LjI3IiwiaHR0cHM6Ly9hdXRoLmR0bi5jb20vcnBzIjoiMTAwIiwiaHR0cHM6Ly9hdXRoLmR0bi5jb20vdGllciI6IkJhc2ljIiwiaHR0cHM6Ly9hdXRoLmR0bi5jb20vcXVvdGEiOiI5OTk5OTkiLCJpc3MiOiJodHRwczovL2lkLmF1dGguZHRuLmNvbS8iLCJzdWIiOiJuZnlPM0tpS1BSOE4wREtSNUNMOGpTOUdGQkNEZXlGTUBjbGllbnRzIiwiYXVkIjoiaHR0cHM6Ly9kZW1vLWFwaS5hdXRoLmR0bi5jb20vIiwiaWF0IjoxNjU2MDk5MDY4LCJleHAiOjE2NTYwOTkxNTgsImF6cCI6Im5meU8zS2lLUFI4TjBES1I1Q0w4alM5R0ZCQ0RleUZNIiwic2NvcGUiOiJyZWFkOmRlbW8gY3JlYXRlOmRlbW8gdXBkYXRlOmRlbW8iLCJndHkiOiJjbGllbnQtY3JlZGVudGlhbHMiLCJwZXJtaXNzaW9ucyI6WyJyZWFkOmRlbW8iLCJjcmVhdGU6ZGVtbyIsInVwZGF0ZTpkZW1vIl19.0VHdyp1w9PPFVI0FPheAwuKZwb5C25rwP-LPMXcSNoRmouvga1DZtNLA67ZzE_sAlc_VpaDRr6daLKr_Alw4347mw9sdjP8wKR27kCZa9JZK5PGQMmXHscATbzBEJYpCPklfyGaajgymqTBGnedcv8F0UvlRzQPsFeRPnVoX7BWOSXpMbyToGiXWkQLBQT7r96KAmLZOPJFZspPtjw-wH2mSL2WNa_nkB4j5vMGhGxlKiNRsKb30TH_WAel2hsxNlcPK3XHCmrMTYsNnu7HNqOTMn2i0__0rvBrhSWEw-_grqQDmWFJuWd7Qhi1q81AaJcdqgoSa_efz93QFclJUNw\",\n \"scope\": \"read:demo create:demo update:demo\",\n \"expires_in\": 90,\n \"token_type\": \"Bearer\"\n },\n \"meta\": {\n \"date_time\": \"2022-06-24T19:09:42.963Z\",\n \"name\": \"v1.tokens.authorize\",\n \"uuid\": \"ee6f9feb-dcf8-4421-a6fd-efd6beabdaa9\",\n \"start_timestamp\": 1656097782509,\n \"end_timestamp\": 1656097782963,\n \"execution_time\": 454\n }\n }\n ```\nLooking at this Response, you will see:\n * `access_token`: contains the JWT Access Token string you will use as your Bearer token.\n * `scope`: contains the scopes that this Access Token gives you permissions to access.\n * `expires_in`: contains the length of time before this Access Token will expire, in seconds.\n * `token_type`: verifies that this Access Token should be used as a Bearer token.\n\n## How to use an Access Token after one is generated?\nOnce a new Access Token is obtained, it is used in each call to a DTN API endpoint as a Bearer token in an Authorization Request Header. For example:\n ```\n Header: 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6InpfX21pZW13NGhoTmdvQWQxR3N6ciJ9.eyJodHRwczovL2F1dGguZHRuLmNvbS9jdXN0b21lcklkIjoiMTIzNDU2Nzg5MERlbW8iLCJodHRwczovL2F1dGguZHRuLmNvbS9wcm9kdWN0Q29kZSI6IkRlbW9BcGlQIiwiaHR0cHM6Ly9hdXRoLmR0bi5jb20vcmVxdWVzdGVySXAiOiIxOC4yMTMuMTc0LjI3IiwiaHR0cHM6Ly9hdXRoLmR0bi5jb20vcnBzIjoiMTAwIiwiaHR0cHM6Ly9hdXRoLmR0bi5jb20vdGllciI6IkJhc2ljIiwiaHR0cHM6Ly9hdXRoLmR0bi5jb20vcXVvdGEiOiI5OTk5OTkiLCJpc3MiOiJodHRwczovL2lkLmF1dGguZHRuLmNvbS8iLCJzdWIiOiJuZnlPM0tpS1BSOE4wREtSNUNMOGpTOUdGQkNEZXlGTUBjbGllbnRzIiwiYXVkIjoiaHR0cHM6Ly9kZW1vLWFwaS5hdXRoLmR0bi5jb20vIiwiaWF0IjoxNjU2MDk5MDY4LCJleHAiOjE2NTYwOTkxNTgsImF6cCI6Im5meU8zS2lLUFI4TjBES1I1Q0w4alM5R0ZCQ0RleUZNIiwic2NvcGUiOiJyZWFkOmRlbW8gY3JlYXRlOmRlbW8gdXBkYXRlOmRlbW8iLCJndHkiOiJjbGllbnQtY3JlZGVudGlhbHMiLCJwZXJtaXNzaW9ucyI6WyJyZWFkOmRlbW8iLCJjcmVhdGU6ZGVtbyIsInVwZGF0ZTpkZW1vIl19.0VHdyp1w9PPFVI0FPheAwuKZwb5C25rwP-LPMXcSNoRmouvga1DZtNLA67ZzE_sAlc_VpaDRr6daLKr_Alw4347mw9sdjP8wKR27kCZa9JZK5PGQMmXHscATbzBEJYpCPklfyGaajgymqTBGnedcv8F0UvlRzQPsFeRPnVoX7BWOSXpMbyToGiXWkQLBQT7r96KAmLZOPJFZspPtjw-wH2mSL2WNa_nkB4j5vMGhGxlKiNRsKb30TH_WAel2hsxNlcPK3XHCmrMTYsNnu7HNqOTMn2i0__0rvBrhSWEw-_grqQDmWFJuWd7Qhi1q81AaJcdqgoSa_efz93QFclJUNw'\n ```\n\n## Deconstructing the Access Token\nA DTN Access Token carries information within its JWT Body that is available on every API call. By deconstructing the JWT token, our Access Tokens will resemble:\n ```\n {\n \"https://auth.dtn.com/customerId\": \"1234567890Demo\",\n \"https://auth.dtn.com/productCode\": \"DemoApiP\",\n \"https://auth.dtn.com/requesterIp\": \"18.213.174.27\",\n \"https://auth.dtn.com/rps\": \"100\",\n \"https://auth.dtn.com/tier\": \"Basic\",\n \"https://auth.dtn.com/quota\": \"999999\",\n \"iss\": \"https://id.auth.dtn.com/\",\n \"sub\": \"nfyO3KiKPR8N0DKR5CL8jS9GFBCDeyFM@clients\",\n \"aud\": \"https://demo-api.auth.dtn.com/\",\n \"iat\": 1656099068,\n \"exp\": 1656099158,\n \"azp\": \"nfyO3KiKPR8N0DKR5CL8jS9GFBCDeyFM\",\n \"scope\": \"read:demo create:demo update:demo\",\n \"gty\": \"client-credentials\",\n \"permissions\": [\n \"read:demo\",\n \"create:demo\",\n \"update:demo\"\n ]\n }\n ```\n### Description of Claims\n\n | Claim | Type | Description |\n | -----------------------------------| --------------------------------------------| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n | `https://auth.dtn.com/customerId` | String | Custom DTN claim containing the Customer ID found in the DTN Order Management/Salesforce system associated with this token. |\n | `https://auth.dtn.com/productCode` | String | Custom DTN claim containing the Identity product code associated with this token. |\n | `https://auth.dtn.com/requesterIp` | String | Custom DTN claim containing the IP address of the requesting client. |\n | `https://auth.dtn.com/rps` | String | Custom DTN claim containing the maximum rate per second this customer is authorized to utilize. |\n | `https://auth.dtn.com/tier` | String | Custom DTN claim containing the data tier the customer purchased for the requested access. |\n | `https://auth.dtn.com/quota` | String | Custom DTN claim containing the maximum yearly quota the customer purchased for calling DTN endpoints for the specific product. |\n | `iss` | String (URI) | The Security Token Service (STS) that issues and returns the token. If this value is not from `https://id.auth.dtn.com/`, the token should not be considered trusted. |\n | `sub` | String (URI) | The principle about which the token asserts information (the User ID or Client ID within the Identity Provider). A User ID will start with a prefix of `auth0\\|`, while the Client ID will end with the suffix `@clients`. |\n | `aud` | String \\| Array (Strings) (URI \\| [URI, …]) | Identifies the intended recipient(s) of the token – its audience. The token should be rejected if the audience does not contain values expected by the calling application. |\n | `iat` | Number (Timestamp) | “Issued At” indicates when the authentication for this token occurred. |\n | `exp` | Number (Timestamp) | The “expiration time” on or after which the JWT must not be accepted for processing. |\n | `azp` | String | The application/client ID of the client using the token. The application can cat as itself or on behalf of a user. |\n | `gty` | String (Space-delimited) | The grant type that was used to request the token – not an RFC 7519 registered claim (Auth0-specific). |\n | `permissions` | Array (Strings) | The grant type that was used to request the token – not an RFC 7519 registered claim (Auth0-specific). |\n\n "}}}}