Metadata-Version: 2.1
Name: cryptokeyhole
Version: 1.2.1
Summary: CryptoKeyhole data client: on-chain and market charts, SQL, every coin's series in one call and nightly files from the CryptoKeyhole API
Home-page: https://cryptokeyhole.com/data-access/
Author: CryptoKeyhole
License: MIT
Project-URL: Documentation, https://cryptokeyhole.com/data-access/
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Office/Business :: Financial
Requires-Python: >=3.8
Provides-Extra: pandas
Requires-Dist: pandas; extra == "pandas"
Description-Content-Type: text/markdown

# cryptokeyhole.py

CryptoKeyhole chart data for Python: series for BTC, ETH, LINK and every other asset on CryptoKeyhole (https://cryptokeyhole.com),
with the same four functions as the Google Sheets script and the Excel add-in, plus SQL and bulk reads for paid plans.

```sh
pip install https://cryptokeyhole.com/data-access/sdk/cryptokeyhole-1.2.1-py3-none-any.whl   # adds the cryptokeyhole command
```

- One file, standard library only, Python 3.8 or later. `to_dataframe()` also needs pandas. Installing is optional:
  the file works next to your script.
- Without an API key you read the Free view: daily, weekly, monthly and yearly values of the Free charts.
- With a key (Plus and higher plans) you read what your plan includes. Set `CRYPTOKEYHOLE_API_KEY`,
  or pass `api_key=`. The key is sent only in the Authorization header and never printed or logged.

```python
import cryptokeyhole as ckh

client = ckh.Client()
prices = client.values("eth.PriceUSD", "24h", start="2024-01-01")   # time, value, finality
frame = prices.to_dataframe()
when, price, finality = client.latest("link.PriceUSD")
client.series("blockchain.BlockCount", "1M", start="2015-01-01").to_csv("block-count.csv")
charts = client.metrics("ETH")                                       # id, name, unit, intervals, status, access
```

| Function | Returns |
|---|---|
| `values(metric, interval, start, end, sma, smoothing)` | chart values as numbers, one column per line of the chart, and the row's finality |
| `latest(metric, interval)` | the newest row with a value: `[time, value, ..., finality]` |
| `series(metric, interval, start, end, sma, smoothing, publication)` | exact observations: 21 text columns with finality, source clocks and provenance |
| `metrics(asset)` | the charts of an asset (BTC, ETH, SOL, ...; `assets()` lists them) and whether your plan includes them |
| `every_coin(metric, assets, start, end)` | one chart for every coin that publishes it, daily values, in one request (Plus and higher) |
| `sql(query, max_rows)` | one read-only SQL statement over every chart's daily values (Pro, API & Team); `sql_schema()` lists the tables |
| `bulk_files()` / `download(file, path)` | the nightly files (Pro: each coin; API & Team: also the whole database) and a checked download |

A saved formula reads like a chart: `client.values("formula:<id>")` with its share id, or with your key the id of one
of your own saved formulas (its saved interval and range apply unless given; at most 20,000 rows per call).

Also: `metric(id)`, `bulk(metrics, ...)` with `wide_dataframe(...)`, `export(...)` (the chart pages' CSV or
JSON download, Plus and higher) and `assets()`. Errors raise `PlanRequired`, `QuotaExceeded`,
`AuthenticationError` or `DataUnavailable`, all `CryptoKeyholeError`, with the API's own message.

Command line: `cryptokeyhole values eth.PriceUSD --start 2024-01-01 > eth-price.csv` (or `python cryptokeyhole.py ...`);
also `latest`, `series`, `metrics`, `every-coin`, `sql`, `files` and `download`.

The client code is MIT-licensed. Full guide, plans and API calls, and data reuse terms: https://cryptokeyhole.com/data-access/
