⚠️ Blackout Events
Instant snapshot of all vessels being in blackout (i.e not sending any AIS signal since more than 24 hours) and duration of the blackout event.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import requests
import pandas as pd
from datetime import datetime, timezone
# Base url
url = "https://apihub.axsmarine.com/tanker/ship-status/current/v2?"
params = {
"page_size" : "5000",
}
# Add token
token = "INSERT MY TOKEN"
headers = {
"Authorization": "Bearer {}".format(token)
}
# Add parameters
for name,value in params.items():
url = url + "&" + name + "=" + value
print("Url to query :", url)
response = requests.get(url, headers=headers).json()
total = pd.DataFrame(response['results'])
next_url = response['links']['next']
# Loop to get all results
while next_url is not None:
response = requests.get(next_url, headers=headers).json()
df = pd.DataFrame(response['results'])
next_url = response['links']['next']
total = pd.concat([total,df])
total = total.loc[total['in_blackout_since'].notna()]
now = datetime.now(timezone.utc)
total['blackout_duration'] = (now - pd.to_datetime(total['in_blackout_since'])).dt.days