SDKs
Code samples
The API is small enough that a typed package isn't needed yet. These thin clients handle auth, quotas and errors — copy one into your project.
# List what you can call curl https://data.xaucloud.io/api/data/v1/catalog # Check your quota curl https://data.xaucloud.io/api/data/v1/usage -H "Authorization: Bearer $XAUCLOUD_DATA_KEY"
import os, requests
class XauCloudData:
BASE = "https://data.xaucloud.io/api/data/v1"
def __init__(self, key=None):
self.s = requests.Session()
self.s.headers["Authorization"] = f"Bearer {key or os.environ['XAUCLOUD_DATA_KEY']}"
def dataset(self, name, limit=25):
r = self.s.get(f"{self.BASE}/datasets/{name}", params={"limit": limit}, timeout=10)
if r.status_code == 429:
raise RuntimeError("Quota reached; retry in the next window")
r.raise_for_status()
return r.json()
def usage(self):
return self.s.get(f"{self.BASE}/usage", timeout=10).json()
xc = XauCloudData()
print(xc.dataset("signals", limit=10)["rows"][0])export class XauCloudData {
constructor(key = process.env.XAUCLOUD_DATA_KEY) {
this.base = "https://data.xaucloud.io/api/data/v1";
this.headers = { Authorization: `Bearer ${key}` };
}
async dataset(name, limit = 25) {
const res = await fetch(`${this.base}/datasets/${name}?limit=${limit}`, { headers: this.headers });
if (res.status === 429) throw new Error("Quota reached; retry in the next window");
if (!res.ok) throw new Error(`XauCloud Data ${res.status}: ${(await res.json()).error}`);
return res.json();
}
usage() {
return fetch(`${this.base}/usage`, { headers: this.headers }).then((r) => r.json());
}
}
const xc = new XauCloudData();
console.log((await xc.dataset("forecasts", 1)).rows[0]);