Skip to content

Instantly share code, notes, and snippets.

@elpatron68
Created November 19, 2021 18:08
Show Gist options
  • Save elpatron68/b016eb60eb7b4ff7198f552b188ae319 to your computer and use it in GitHub Desktop.
Save elpatron68/b016eb60eb7b4ff7198f552b188ae319 to your computer and use it in GitHub Desktop.
Get a boat´s position from Sailaway public API
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