iturri 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.mjs +28 -6
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -2,14 +2,21 @@
2
2
  // Every bar carries a quality flag; filter on it.
3
3
  // Data and tooling only — never signals, predictions, or financial advice.
4
4
 
5
- export const BASE_URL = "https://iturri-data.odd-haze-3940.workers.dev";
5
+ export const BASE_URL = "https://iturri.ai";
6
+
7
+ // membership token: setToken("...") or ITURRI_TOKEN env (node)
8
+ export let token = (typeof process !== "undefined" && process.env?.ITURRI_TOKEN) || null;
9
+ export const setToken = (t) => { token = t; };
10
+ const authHeaders = () => (token ? { authorization: `Bearer ${token}` } : {});
6
11
  export const QUALITY = ["verified", "raw", "reconciled", "interpolated", "disputed", "outage"];
7
12
 
8
13
  async function get(path, params) {
9
14
  const url = new URL(BASE_URL + path);
10
15
  for (const [k, v] of Object.entries(params ?? {}))
11
16
  if (v !== undefined && v !== null) url.searchParams.set(k, v);
12
- const r = await fetch(url);
17
+ const r = await fetch(url, { headers: authHeaders() });
18
+ if (r.status === 402)
19
+ throw new Error("402 payment required — setToken()/ITURRI_TOKEN with a membership token from https://iturri.ai/subscribe, or pay per-call with an x402 client");
13
20
  if (!r.ok) throw new Error(`iturri api ${r.status}: ${(await r.json()).error ?? r.statusText}`);
14
21
  return r.json();
15
22
  }
@@ -37,11 +44,26 @@ export async function features(symbol, tf, { start, end } = {}) {
37
44
  }));
38
45
  }
39
46
 
40
- /** Signed download URLs for a training pack: "crypto" | "equities". */
41
- export async function bundle(pack) {
47
+ /** Funding settlement history from listing date. */
48
+ export const funding = (symbol, o = {}) => get("/api/funding", { symbol, ...o });
49
+ /** Hourly open interest with quality flags. */
50
+ export const openInterest = (symbol, o = {}) => get("/api/oi", { symbol, ...o });
51
+ /** Taker buy/sell imbalance + trade counts (tf: 1h|1d). */
52
+ export const orderflow = (symbol, o = {}) => get("/api/orderflow", { symbol, ...o });
53
+ /** Context series: fear_greed_1d, VIX_1d, DXY_1d, TNX_1d, DJI_1d. */
54
+ export const context = (series, o = {}) => get("/api/context", { series, ...o });
55
+ /** Curated events (FOMC w/ surprise, halvings, incidents). */
56
+ export const events = (o = {}) => get("/api/events", o);
57
+ /** Descriptive market-state label at or before a timestamp. */
58
+ export const regime = (symbol, timestamp) => get("/api/regime", { symbol, timestamp });
59
+ /** Data-quality report for a spec before you backtest on it. */
60
+ export const validate = (symbol, tf, o = {}) => get("/api/validate", { symbol, tf, ...o });
61
+
62
+ /** Signed download URLs: pack "crypto"|"equities", or "tokens" with a symbol. */
63
+ export async function bundle(pack, symbol) {
42
64
  const r = await fetch(BASE_URL + "/api/bundle", {
43
- method: "POST", headers: { "content-type": "application/json" },
44
- body: JSON.stringify({ pack }),
65
+ method: "POST", headers: { "content-type": "application/json", ...authHeaders() },
66
+ body: JSON.stringify({ pack, symbol }),
45
67
  });
46
68
  if (!r.ok) throw new Error(`iturri api ${r.status}`);
47
69
  const out = await r.json();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iturri",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Client + CLI for the Iturri verified market-data API — every bar verified or flagged",
5
5
  "type": "module",
6
6
  "main": "index.mjs",