Skip to content

Latest commit

 

History

History
65 lines (38 loc) · 1.42 KB

README.md

File metadata and controls

65 lines (38 loc) · 1.42 KB

Python API Client for NIWA's APIs

This Python package provides a convenient way to interact with NIWA's APIs. It includes functionality to fetch tide data, generate tide charts, and handle various data formats.

Disclaimer: This is not an official NIWA package. I have nothing to do with NIWA other than enjoying using their open APIs.

Installation

You can install the package using pip:

pip install niwa-api-client

Usage

Tide Data

To fetch tide data, you can use the TideAPIClient class. Here's an example of how to use it:

from niwa_api import TideAPIClient

client = TideAPIClient(api_key='YOUR_API_KEY')
data = client.get_data(lat=lat, long=long)
print(data)

CLI

The package also includes a command-line interface (CLI) for interacting with the APIs. You can use the niwa-tides command to fetch tide data or generate tide charts.

Fetch Tide Data

To fetch tide data, use the fetch-tide-data command:

niwa-tides --lat -36 --long 174 

To fetch the tide chart as a PNG image, use the format and output options:

niwa-tides --lat -36 --long 174 --format png --output tide.png

Using an API Key in the cli

You can either pass the api key as an argument:

niwa-tides --lat -36 --long 174 --api-key YOUR_API_KEY

Or set the NIWA_API_KEY environment variable:

export NIWA_API_KEY=YOUR_API_KEY
niwa-tides --lat -36 --long 174