aibank
SDK Reference

AibankCatalog

Client for the service catalog. Discover, subscribe to, and call registered third-party services.

AibankCatalog

Client for browsing the service catalog, subscribing to services, and making proxied API calls. Access via aibank.catalog.

const catalog = aibank.catalog;

The instance is created lazily and reused across calls.

Methods

listServices(opts?)

Browse all active services in the catalog.

const services = await aibank.catalog.listServices({
  category: "data",
  search: "weather",
});

for (const svc of services) {
  console.log(`${svc.name} - $${svc.price_per_call_usd}/call`);
}

Parameters:

PropertyTypeDescription
categorystringOptional category filter
searchstringOptional keyword search (matches name and description)

Returns: Promise<CatalogService[]>

getService(serviceId)

Fetch full details for a service including its OpenAPI spec and agent-friendly summary.

const detail = await aibank.catalog.getService("service-uuid");

console.log(detail.agent_summary);
console.log(detail.endpoints);
// [{ method: "GET", path: "/forecast", summary: "..." }]

Returns: Promise<CatalogServiceDetail>

subscribe(serviceId, walletId)

Subscribe a wallet to a service for usage tracking and billing.

const sub = await aibank.catalog.subscribe("service-uuid", "wallet-uuid");
console.log(sub.subscription_id);
console.log(sub.status); // "active"

Returns: Promise<Subscription>

unsubscribe(serviceId, walletId)

Cancel a subscription.

await aibank.catalog.unsubscribe("service-uuid", "wallet-uuid");

Returns: Promise<void>

call(serviceId, path, opts?)

Proxy an HTTP call to a registered service. The API key is automatically injected.

const response = await aibank.catalog.call(
  "service-uuid",
  "/forecast?city=London"
);

const data = await response.json();
console.log(data);

With POST:

const response = await aibank.catalog.call(
  "service-uuid",
  "/analyze",
  {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ text: "Analyze this" }),
  }
);

Parameters:

PropertyTypeDescription
serviceIdstringService UUID
pathstringSub-path on the service (e.g. /search)
optsRequestInitOptional fetch init (method, headers, body)

Returns: Promise<Response> -- raw Response from the upstream service.

Type definitions

interface CatalogService {
  id: string;
  name: string;
  description: string | null;
  base_url: string;
  pricing_model: string;
  price_per_call_usd: number;
  category: string | null;
  total_calls: number;
  created_at: string;
}

interface CatalogServiceDetail extends CatalogService {
  total_revenue_usd?: number;
  openapi_spec: unknown;
  agent_summary: string;
  endpoints: ServiceEndpoint[];
}

interface ServiceEndpoint {
  method: string;
  path: string;
  summary?: string;
  parameters?: unknown[];
}

interface Subscription {
  subscription_id: string;
  service_id: string;
  service_name: string;
  wallet_id: string;
  status: "active" | "cancelled" | "paused";
  reactivated?: boolean;
}

Full example

import { Aibank } from "aibank";

const aibank = new Aibank({
  apiKey: "ak_your_key",
  walletBaseUrl: "http://localhost:4000",
});

// 1. Browse available services
const services = await aibank.catalog.listServices();
console.log(`Found ${services.length} services`);

// 2. Get details for the first service
const detail = await aibank.catalog.getService(services[0].id);
console.log("Summary:", detail.agent_summary);
console.log("Endpoints:", detail.endpoints);

// 3. Subscribe a wallet
const wallet = await aibank.createWallet({ name: "catalog-consumer" });
const sub = await aibank.catalog.subscribe(services[0].id, wallet.id);

// 4. Call the service
const endpoint = detail.endpoints[0];
const response = await aibank.catalog.call(
  services[0].id,
  endpoint.path
);
const data = await response.json();
console.log("Result:", data);

// 5. Unsubscribe when done
await aibank.catalog.unsubscribe(services[0].id, wallet.id);

On this page