TonikAPI

## Overview

TonikAPI is designed for efficient retrieval, transformation, and feature extraction of time-series and spectrogram-like data stored in hierarchical formats. It supports subdirectory traversal, resampling, log-scaling, and normalization.

This API is especially suited for applications in seismology, geophysics, and related fields.

## Endpoints

Endpoint | Method | Description
--- | --- | ---
`/feature` | GET | Returns time series or spectrogram features for a given group, variable, and time range.
`/inventory` | GET | Lists available datasets or subdirectories within a group.
`/labels` | GET | Fetches labels associated with a dataset for a specified time range.

## Feature Request Example

Example query for retrieving a feature:

    GET /feature?group=testgroup&name=rms&starttime=2023-01-01T00:00:00&endtime=2023-01-02T00:00:00&resolution=1h&log=true&normalise=true

Try Feature Query

    curl "http://localhost:8003/feature?group=testgroup&name=rms&starttime=2023-01-01T00:00:00&endtime=2023-01-02T00:00:00&resolution=1h&log=true&normalise=true"

## Inventory and Labels

Query inventory of datasets:

    GET /inventory?group=testgroup

Query labels for a dataset:

    GET /labels?group=testgroup&starttime=2023-01-01T00:00:00&endtime=2023-01-02T00:00:00

## Python Example

You can query the TonikAPI directly from Python using `requests`:

    import requests

    params = {
        "group": "testgroup",
        "name": "rms",
        "starttime": "2023-01-01T00:00:00",
        "endtime": "2023-01-02T00:00:00",
        "resolution": "1h",
        "log": "true",
        "normalise": "true"
    }

    response = requests.get("http://localhost:8003/feature", params=params)
    with open("rms_feature.csv", "w") as f:
        f.write(response.text)