The following python script
- Code: Select all
import httplib, urllib, base64
headers = {
# Request headers
'Ocp-Apim-Subscription-Key': '<your-api-key>',
}
params = urllib.urlencode({
})
try:
conn = httplib.HTTPSConnection('admiraltyapi.azure-api.net')
conn.request("GET", "/uktidalapi/api/V1/Stations/0027/TidalEvents?duration=1%s" % params, "{body}", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
generates the output
- Code: Select all
[{"EventType":"LowWater","DateTime":"2018-09-12T02:10:42","IsApproximateTime":false,"Height":-0.11082818269453196,"IsApproximateHeight":false,"Filtered":false},{"EventType":"HighWater","DateTime":"2018-09-12T08:19:45.35","IsApproximateTime":false,"Height":4.1403555545034791,"IsApproximateHeight":false,"Filtered":false},{"EventType":"LowWater","DateTime":"2018-09-12T14:26:00","IsApproximateTime":false,"Height":-0.0073008353119995983,"IsApproximateHeight":false,"Filtered":false},{"EventType":"HighWater","DateTime":"2018-09-12T20:31:11.15","IsApproximateTime":false,"Height":4.2886176564094765,"IsApproximateHeight":false,"Filtered":false}]
Once you have created an API key in the subscriptions part of the website, you can insert it in the script. This example is for station 0027, and a duration of "1" is just today.
That should give you a start to selecting the parts you want and populating the variables. I am way out of my depth but fancied trying to figure it out.
I also tried using GhostXML, but not sure how you can pass the API token as a header, if anyone can help with a pointer for that it becomes a whole lot easier.
I will keep playing, but suspect I am at the end of my knowledge / python skills.