TemplatesDocs
All templates

Neobank

Business banking on the Whop API: balances, corporate cards and money movement.
Read the docs

Code

$npm install @whop/sdk
app/api/overview/route.ts
const WHOP = "https://api.whop.com/api/v1";
const auth = { Authorization: `Bearer ${process.env.WHOP_API_KEY}` };

export async function GET() {
  const account = await fetch(`${WHOP}/accounts/me`, { headers: auth }).then((r) => r.json());

  const activity = await fetch(
    `${WHOP}/financial-activity?account_id=${account.id}`,
    { headers: auth },
  ).then((r) => r.json());

  return Response.json({
    balances: account.balances,
    total_usd: account.total_usd,
    ledger: activity.data,
    cursor: activity.page_info.end_cursor,
  });
}
data/http-endpoints.ts
import type { NeobankEndpoints } from "./endpoints";

const get = async (path: string) => {
  const response = await fetch(`/api${path}`, { credentials: "include" });
  if (!response.ok) throw new Error(`${path} failed (${response.status})`);
  return response.json();
};

export const httpAPI: NeobankEndpoints = {
  getAccount: () => get("/account"),
  listFinancialActivity: () => get("/financial-activity"),
  listCards: () => get("/cards"),
  listCardTransactions: () => get("/card-transactions"),
};

<NeobankDataProvider endpoints={httpAPI}>

<NeobankDataProvider endpoints={{ ...mockEndpoints, getAccount: httpAPI.getAccount }}>