Skip to main content

Python library for interfacing with the UKHO Admiralty Tidal API

Project description

UKHO Tides

This package provides a client wrapper for the Admiralty Tidal API endpoints.

Installation

Install via pip.

pip install ukhotides

API Key

To call the API you will need an API key from the Admiralty Maritime Data Solutions developer portal. Follow their guide on how to do so and select one of the UK Tidal API products - the Discovery tier is free (the paid APIs have not been tested for this package).

Usage

from ukhotides import UkhoTides
from aiohttp import ClientSession

session = ClientSession()
client = UkhoTides(session, "<api_key>")

# Get all stations
stations = await client.async_get_stations()

# Get stations with name filter
stations = await client.async_get_stations("StationName")

# Get station by id
station = await client.async_get_station("0001")

# Get tidal events for station by id
events = await client.async_get_tidal_events("0001")

# Get 4 days of tidal events for station by id
events = await client.async_get_tidal_events("0001", 4)

There are also several premium endpoints exposed, however these are built based on the documentation and have not been tested.

### Premium API Endpoints ###
### UNTESTED ###
from ukhotides import UkhoTides, ApiLevel
from aiohttp import ClientSession
from datetime import datetime

session = ClientSession()
client = UkhoTides(session, "<api_key>", ApiLevel.Premium)

# Get tidal events for a station between a given date range
start_date = datetime(2020,1,1)
end_date = datetime(2020,1,30)
events = await client.async_get_tidal_events_for_date_range("0001", start_date, end_date)

# Get tide height for a station for a given datetime
date_time = datetime(2020,1,1)
height = await client.async_get_tidal_height("0001", date_time)

# Get tide heights for a station between a given date range and at a given interval
interval_in_minutes = 60
start_date = datetime(2020,1,1)
end_date = datetime(2020,1,1,2)
heights = await client.async_get_tidal_heights("0001", start_date, end_date, interval_in_minutes)

Publish to PyPi

Update the version number in pyproject.toml and then run:

poetry config pypi-token.pypi $PYPI_TOKEN
poetry publish --build

TODO

  • Better docs (sorry)
  • Webhooks to automate distribution and versioning

Attribution

Contains ADMIRALTY® Tidal Data: © Crown copyright and database right

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ukhotides-1.1.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ukhotides-1.1.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file ukhotides-1.1.1.tar.gz.

File metadata

  • Download URL: ukhotides-1.1.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.10.15 Linux/5.15.153.1-microsoft-standard-WSL2

File hashes

Hashes for ukhotides-1.1.1.tar.gz
Algorithm Hash digest
SHA256 cfd7b9aa47d081842a14b2d3e29dcbfb47b5fcccaa2fd18c1f3a8ebe0d8eabfa
MD5 ef8de26952f723fb7438da48987f485d
BLAKE2b-256 078d9b1a88eb8b03d05685aebf3ebd0731e4b4bba8d0b7ff677450a60872279a

See more details on using hashes here.

File details

Details for the file ukhotides-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: ukhotides-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.10.15 Linux/5.15.153.1-microsoft-standard-WSL2

File hashes

Hashes for ukhotides-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d65506a0f3043d94af2b1dde31dbd19d2c6b2b88d4840bb6a7baae2ae680c89a
MD5 50812c786c68bb25fcc9c6b0468f41a7
BLAKE2b-256 b1477bb00af1fd172cc44876366a1f6943e4218288906245c94526e768fbac07

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page