# Programmatic access

The data is already an API. Everything is static and public, addressed by URL: nothing to authenticate, nothing to rate limit. A REST service would add cost and failure modes without reach.

## What works today

| need | how |
|---|---|
| list the releases | `GET /studies/` (HTML), or `src/data/studies_index.json` (the same list as JSON) |
| one release | `GET <base>/<accession>-<date>/manifest.json` |
| one table | a range request against `<base>/<dir>/tables/<accession>.counts.parquet` |
| pooled taxa | `GET /taxa/` and the generated taxa index JSON beside it |
| metadata for all releases | `studies_index.json`, `downloads_index.json`, `release_dates.json`, `taxa_index.json` |

The base URL is `https://huggingface.co/datasets/hmacgregor/ampliconflow-releases/resolve/main/`, and
the object store behind it speaks the S3 API, so `aws s3 sync --endpoint-url https://s3.hf.co` works
with any S3 client.

## Why not a REST API

- Each release is read-only and small (tens of MB). Parquet with range requests filters client side, cheaper than a round trip per query.
- A server needs hosting, a cache and a schema. The static site needs none of them and stays up with the CDN.
- Files are auditable: a DOI, a manifest and a sha256 can be checked. An endpoint cannot.

## If a live API is wanted later

Two cheap options, both keeping the static files as the source of truth:

1. **Cloudflare Pages Functions** in front of the same URLs, so `/api/studies?tag=soil` returns JSON
   computed from the same index files. Free tier covers a low-traffic research service.
2. **DuckDB over the parquet URLs**: any client can point DuckDB at the HTTPS paths and run SQL
   without a server at all. This is the closest thing to a query API and needs no new infrastructure.

Recommendation: ship the documented static contract now, add Functions only if a specific consumer
needs server-side joins.
