Use GalliunClient.fetch() to call any protected API endpoint registered on the Galliun platform.

Basic POST request

const client = new GalliunClient({
  baseUrl: "https://api.galliun.com",
  chain: "sui",
  wallet: suiWallet,
});

const response = await client.fetch("/p/acme/search", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ query: "best restaurants in Tokyo" }),
});

const data = await response.json();

GET requests

const response = await client.fetch("/p/acme/status", {
  method: "GET",
});

JSON helper

const data = await client.fetchJson<{ results: string[] }>("/p/acme/search", {
  method: "POST",
  body: JSON.stringify({ query: "hello" }),
});

fetchJson throws APIError on non-OK responses with statusCode and responseBody.

Request body

Response handling

Successful responses return a standard Response object. Many endpoints include payment metadata in the JSON body:

{
  "result": { "...": "..." },
  "payment": {
    "status": "captured",
    "chain": "sui",
    "asset": "USDC",
    "amount": "0.005",
    "txHashOrDigest": "..."
  },
  "cost": {
    "gross": "0.005",
    "platformFee": "0.0001",
    "providerNet": "0.0049"
  },
  "receiptId": "receipt_..."
}

See Receipts and Cost Breakdown.

Failure states

Status Error Meaning
402 payment_required Payment missing or invalid (after retry)
503 endpoint_unavailable Endpoint disabled or unhealthy
4xx/5xx varies Upstream or validation error

After payment succeeds but execution fails with a refund-recommended outcome, the response may include refundRecommendationId and refundRecommendationStatus: "recommended". Galliun does not issue refunds — see Refunds.

Common mistakes

Next steps