Created
November 19, 2021 18:08
-
-
Save elpatron68/b016eb60eb7b4ff7198f552b188ae319 to your computer and use it in GitHub Desktop.
Get a boat´s position from Sailaway public API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
# API_KEY and USRNR from https://sailaway.world/cgi-bin/sailaway.world/myaccount.pl | |
API_KEY = 'your API key' | |
USRNR = 'your USNR' | |
API_BASE_URL = 'http://srv.sailaway.world/cgi-bin/sailaway' | |
def getBoatPosition(boatname): | |
params = dict( | |
key=API_KEY, | |
usrnr=USRNR, | |
) | |
url = f'{API_BASE_URL}/APIBoatInfo.pl' | |
resp = requests.get(url=url, params=params) | |
data = resp.json() | |
for boat in data: | |
if boat['boatname'] == boatname: | |
lat = boat['latitude'] | |
lon = boat['longitude'] | |
return(lat, lon) | |
if __name__ == "__main__": | |
# insert your boat´s name here | |
print(getBoatPosition('Dehumanizer')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment