Tonik API Documentation

## Overview

Welcome to the documentation for the Tonik API. This API provides access to time-series stored with the tonik package.

## Endpoints

The endpoints available in the API are:

- GET /feature: Request time-series data.
- GET /inventory: Request information on data.

## Code Examples

### Requesting meta data

The following will return information on available datasets in JSON format.

            curl -X GET "http://your.host.server:yourport/inventory"

To do the same with Python using requests you can use the following code:

            import requests
            url = "http://your.host.server:yourport/inventory"
            response = requests.get(url)
            response.json()

### Requesting data

The following example shows how to request RSAM data for station WIZ at volcano Whakaari between 2019-12-01 and 2019-12-31. The return format is CSV.

        curl -X GET "http://your.host.server:yourport/feature?name=rsam&starttime=2019-12-01T00:00:00&endtime=2019-12-31T00:00:00&subdir=Whakaari&subdir=WIZ"

To do the same with Python using pandas you can use the following code:

            import pandas as pd
            feature="rsam"
            starttime="2019-12-01T00:00:00"
            endtime="2019-12-31T00:00:00"
            volcano="Whakaari"
            site="WIZ"
            url = f"http://your.host.server:yourport/feature?name={feature}&starttime={starttime}&endtime={endtime}&subdir={volcano}&subdir={site}"
            pd.read_csv(url, parse_dates=True, index_col=0)