Skip to main content

View Quickstart Guide

Get started paywalling your API in minutes

What Corbits does for you

  • Merchant discovery: Your endpoints are accessible and usable by agents with no need for new signups, APIs, or accounting setups
  • Pay-per-use: New endpoints are usable in minutes and revenue generating from the first call
  • Plugins, plugins, plugins: Agents are able to utilize new plugins and features to scale the use of your endpoints, all while you get paid

Why merchants love Corbits

  • No account management: No need to worry about managing user management systems as keyless access does the work for you. Same goes for billing, breathe easy.
  • Instant settlemennt: Corbits enables you to get paid out instantly. No need to worry about chargebacks or unpaid credits as every request is accompanied by a settled payment.
  • Unix philosophy: Corbits and Faremeter are composable and scriptable and incredibly open. Our team loves GPLv3 and contribute to cool projects like Bash, DoubleZero, Firedancer, and SVMKit.
  • Enterprise-ready: Use the Corbits toolkit, or host your own. Enterprise-grade security, privacy, and compliance is built-in.

Setting up the middleware

npm install @faremeter/middleware @faremeter/info
import express from "express";
import { express as faremeter } from "@faremeter/middleware";
import { solana } from "@faremeter/info";

const app = express();

// Create the middleware
const paywalledMiddleware = await faremeter.createMiddleware({
  facilitatorURL: "https://facilitator.corbits.dev",
  accepts: [
    {
      ...solana.x402Exact({
        network: "devnet",
        asset: "USDC",
        amount: 10000, // $0.01 in USDC base units
        payTo: "YOUR_WALLET_ADDRESS",
      }),
      resource: "https://yourapi.com/api/premium",
      description: "Premium API access",
    },
  ],
});

// Free endpoint
app.get("/api/free", (req, res) => {
  res.json({ data: "free content" });
});

// Premium endpoint with payment required
app.get("/api/premium", paywalledMiddleware, (req, res) => {
  res.json({ data: "premium content" });
});

app.listen(3000);

Next steps