Storra Cloud

API Client Examples

Reference client implementations using the real API routes. There is no published npm or PyPI package - copy and adapt these examples.

JavaScript

const API_KEY = process.env.CLOUD_API_KEY;
const BASE = "https://cloud.storra.host/api/v1/client";

async function api(method, path, body) {
  const res = await fetch(`${BASE}${path}`, {
    method,
    headers: {
      "X-API-Key": API_KEY,
      ...(body && !(body instanceof FormData)
        ? { "Content-Type": "application/json" }
        : {}),
    },
    body: body instanceof FormData ? body : body ? JSON.stringify(body) : undefined,
  });
  if (!res.ok) throw new Error(await res.text());
  if (res.status === 204) return null;
  return res.json();
}

const me = await api("GET", "/users/me");

const form = new FormData();
form.append("file", fileBlob, "report.pdf");
form.append("path", "documents");
form.append("is_private", "false");
const uploaded = await api("POST", "/files/upload", form);

const files = await api("GET", "/files/list?path=documents&sort=name");

Python

import os
import requests

API_KEY = os.environ["CLOUD_API_KEY"]
BASE = "https://cloud.storra.host/api/v1/client"
HEADERS = {"X-API-Key": API_KEY}

me = requests.get(f"{BASE}/users/me", headers=HEADERS).json()

with open("report.pdf", "rb") as f:
    uploaded = requests.post(
        f"{BASE}/files/upload",
        headers=HEADERS,
        files={"file": ("report.pdf", f)},
        data={"path": "documents", "is_private": "false"},
    ).json()

files = requests.get(
    f"{BASE}/files/list",
    headers=HEADERS,
    params={"path": "documents", "sort": "name"},
).json()

Note

All paths above match the live handlers in src/app/api/v1/client/. See Error Handling for retry logic on 429 responses.

Was this page helpful?