glimglim.shdocs
Quickstart

JavaScript & TypeScript

glim is plain HTTPS + JSON, so built-in fetch (Node 18+, Bun, Deno, browsers) is the whole integration. Add the x402 client if you want to pay per call from a wallet instead of an API key.

With an API key

Create a key at glim.sh/app and send it as an x-api-key header (or Authorization: Bearer):

fetch — API key
const res = await fetch("https://glim.sh/api/v1/web/search", {
  method: "POST",
  headers: {
    "content-type": "application/json",
    "x-api-key": process.env.GLIM_API_KEY,
  },
  body: JSON.stringify({ query: "x402 protocol" }),
});
const data = await res.json();

Pay per call with a wallet

@x402/fetch wraps fetch so a 402 response is paid automatically and retried — no account, no key. Fund the wallet with USDC on Base:

install
npm install @x402/fetch @x402/evm viem
fetch — wallet pays on 402
import { x402Client, wrapFetchWithPayment } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
registerExactEvmScheme(client, {
  signer: privateKeyToAccount(process.env.EVM_PRIVATE_KEY),
});
const fetchWithPayment = wrapFetchWithPayment(fetch, client);

const res = await fetchWithPayment("https://glim.sh/api/v1/web/search", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({ query: "x402 protocol" }),
});
const data = await res.json();
Set Content-Type explicitly. The payment wrapper rebuilds the request on retry, and a string body with no Content-Type defaults to text/plain — so always set content-type: application/json on POST bodies, as above.

Every tool, same shape

Swap the path and body to reach any tool — twitter/search, reddit/get, web/fetch, github/search, and the rest. The OpenAPI spec carries typed schemas and a copy-pasteable example for each; the API reference renders them in the browser.