Skip to content
Developers

Guides

Build a dashboard

Set BANKING_API_KEY in your backend's secret environment. This Bun example requires a separate dashboard session, issued by your application's authentication layer. Do not expose the route publicly or use the banking key as a browser credential.

TypeScript
const api = 'https://api.bankmcp.app/v1';
const key = process.env.BANKING_API_KEY;
if (!key) throw new Error('Missing BANKING_API_KEY');

// Implement this using your application's existing authentication/session library.
import { requireDashboardUser } from './auth';

Bun.serve({
  port: 3000,
  async fetch(request) {
    const user = await requireDashboardUser(request);
    if (!user) return new Response('Unauthorized', { status: 401 });
    // This example is a single-owner dashboard. Multi-user apps must select a
    // different Banking key belonging to each signed-in user.
    const response = await fetch(`${api}/accounts`, {
      headers: { Authorization: `Bearer ${key}` },
    });
    if (!response.ok)
      return Response.json(
        { error: 'Bank data unavailable' },
        {
          status: response.status === 429 ? 429 : 502,
          headers: { 'Cache-Control': 'no-store' },
        },
      );
    const data = await response.json();
    return Response.json(data, { headers: { 'Cache-Control': 'no-store' } });
  },
});

For balances use GET /accounts/{id}/balances; for transactions use GET /accounts/{id}/transactions?limit=100. URL-encode IDs. Follow next_cursor with identical account/date filters until null. The maximum transaction page size is 500. Data may be incomplete: inspect coverage, warning, retrieved_at and complete. Reads do not refresh banks; request POST /banks/{id}/refresh explicitly and allow background jobs to finish. Connection links open the customer portal; the customer must approve the connection at their bank.

Amounts are exact decimal strings. Use decimal arithmetic, keep currencies separate, and avoid double-counting different balance types. Cross-account wallet links may be absent under restricted keys; do not infer invisible transactions or aggregate incomplete data as a full financial total.