Build with AI tools
You can build on the Klupt API without writing the code yourself. Give your AI tool the right file, paste one prompt, and it writes the integration. This page has everything it needs:
- A prompt for app builders like Lovable, Bolt, Replit and v0 (below)
AGENTS.md, a file for your repository that coding agents (Cursor, Codex, Copilot, Claude Code) read before they write code: https://api.klupt.io/AGENTS.md- Every docs page as Markdown in one file: https://api.klupt.io/llms-full.txt, plus an index at /llms.txt. Every page also has a
.mdversion, and docs URLs answer in Markdown when a tool asks fortext/markdown. - The OpenAPI 3.1 spec, for typed clients and code generators: https://api.klupt.io/openapi.json
- The MCP server, if you want your assistant to call the API itself while you chat: MCP server
Rule one: the key stays on the server
Your kd_live_ key spends your credits. Anything that runs in the browser is public: anyone can open the page, find the key in a minute and use your balance. AI app builders often put API calls straight into the page unless you tell them not to.
So every app needs one small piece of server code between your page and the Klupt API:
| Your page (public) | Your server code (private) | Klupt API |
|---|---|---|
| Asks your server: "following of natgeo" | Checks the request, adds X-Api-Key from a secret | Answers with JSON |
Where that server code lives depends on the tool:
| Tool | Server code | Where the key goes |
|---|---|---|
| Lovable | A Supabase Edge Function (or Lovable Cloud) | Secrets, named KLUPT_API_KEY |
| Bolt | A Supabase Edge Function, or a server route in the project | Secrets or environment variables |
| Replit | A small Express or Flask backend in the Repl | Secrets tool (KLUPT_API_KEY) |
| v0 / Next.js | A route handler, for example app/api/klupt/route.ts | Environment variable in your Vercel project |
| Your own repo (Cursor, Claude Code, Codex) | Your existing backend | .env file, never committed |
We help you notice. If a live key is sent from a web page (the request carries a browser Origin header), the answer still works, but it carries meta.warning and an X-Klupt-Warning header telling you to move the call to your server. Test keys never get the warning.
Two more guards, both in the dashboard under API keys:
- IP allowlist: limit the live key to your server's addresses. A leaked key then answers
403 ip_not_allowedeverywhere else. - Monthly credit cap per key: the most a key can ever spend in a month.
Start with a test key
Create a Test key first (it starts with kd_test_). It returns realistic sample data in the exact live schema, costs nothing and never calls Instagram (Sandbox). Let the AI build and debug the whole app on the test key, then swap in a live key as the secret when it works. Nothing else changes.
The prompt
Paste this into Lovable, Bolt, Replit, v0 or any coding agent. Change the first line to what you want to build.
Build: <describe your app, e.g. "a page where I type an Instagram username and see the 20 accounts it followed most recently, newest first">.
Use the Klupt API for the Instagram data.
- Docs for AI (read first): https://api.klupt.io/llms-full.txt
- OpenAPI spec: https://api.klupt.io/openapi.json
- Base URL: https://api.klupt.io/v1
- Auth: header X-Api-Key with the key from a server-side secret named KLUPT_API_KEY.
Rules:
1. Never call https://api.klupt.io/v1 from browser code and never put the key in frontend code, the repo or logs. Create a server function (Supabase Edge Function, API route or backend endpoint) that adds the X-Api-Key header and calls Klupt. The page only calls that function.
2. The server function only allows the endpoints this app needs and checks the input (Instagram usernames match ^[A-Za-z0-9._]{1,30}$). It is not an open proxy.
3. Lists are paged: pass pagination.next_cursor back as ?cursor= for the next page, stop when it is null. Each page costs credits, so only fetch the pages the app shows.
4. followers and following are newest first: position 1 is the most recent follow.
5. Errors come as {"error": {"code", "message"}}. Show a friendly message for private_account, user_not_found, insufficient_credits and rate_limited (wait for the Retry-After header). Failed calls are free.
6. Send the numeric user id instead of the username when you have it: a username lookup costs 1 extra credit.
7. I will start with a kd_test_ key (sample data, free). Do not hard-code sample usernames or data from it.Server code examples
If your tool asks how the server part should look, these are the shapes to aim for. Both only allow the following list and check the username first.
A Supabase Edge Function (Lovable, Bolt). Set the secret with supabase secrets set KLUPT_API_KEY=kd_test_… or in the Supabase dashboard, then call it from the page with supabase.functions.invoke("klupt-following", { body: { username } }):
// supabase/functions/klupt-following/index.ts
const cors = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "authorization, x-client-info, apikey, content-type",
};
Deno.serve(async (req) => {
if (req.method === "OPTIONS") return new Response("ok", { headers: cors });
const { username } = await req.json();
if (typeof username !== "string" || !/^[A-Za-z0-9._]{1,30}$/.test(username)) {
return Response.json({ error: "Invalid username" }, { status: 400, headers: cors });
}
const r = await fetch(`https://api.klupt.io/v1/users/${username}/following`, {
headers: { "X-Api-Key": Deno.env.get("KLUPT_API_KEY")! },
});
return new Response(await r.text(), {
status: r.status,
headers: { ...cors, "Content-Type": "application/json" },
});
});A Next.js route handler (v0, Vercel, your own Next.js app). Add KLUPT_API_KEY under the project's environment variables; the page calls /api/klupt/following?username=natgeo:
// app/api/klupt/following/route.ts
export async function GET(req: Request) {
const username = new URL(req.url).searchParams.get("username") ?? "";
if (!/^[A-Za-z0-9._]{1,30}$/.test(username)) {
return Response.json({ error: "Invalid username" }, { status: 400 });
}
const r = await fetch(`https://api.klupt.io/v1/users/${username}/following`, {
headers: { "X-Api-Key": process.env.KLUPT_API_KEY! },
cache: "no-store",
});
return Response.json(await r.json(), { status: r.status });
}If the app is public, add your own sign-in or a per-visitor limit in front of these functions too: otherwise strangers can spend your credits through your app.
Coding agents in your repository
Cursor, Claude Code, Codex, GitHub Copilot and Windsurf work best with the docs in the repository itself. Save our AGENTS.md next to your code:
curl -o AGENTS.md https://api.klupt.io/AGENTS.mdAlready have an AGENTS.md? Save ours as docs/klupt-api.md and add one line to yours: Klupt API rules: see docs/klupt-api.md. Claude Code reads CLAUDE.md: add the line @AGENTS.md (or @docs/klupt-api.md) to it.
The file holds the base URL, auth, the key rules above, every endpoint with its price, pagination, errors and the sandbox, so the agent does not have to guess. Then ask for what you want, for example "Add a nightly job that saves who @natgeo followed since yesterday, using the Klupt API as described in AGENTS.md."
To give the agent the full reference in a single chat, paste the link https://api.klupt.io/llms-full.txt or the .md URL of one page (every docs page has Copy page and Open in ChatGPT / Claude at the top).
Check what the AI built
Before you go live, check these five things (or ask the AI to check them for you):
- Search the built site for
kd_live_andkd_test_: no match in any file the browser loads. In the browser's developer tools, the Network tab shows no request toapi.klupt.io. - The key comes from a secret or environment variable, not a string in the code, and
.envis in.gitignore. - The server function refuses endpoints the app does not use and bad usernames.
- The app stops at
next_cursor: nulland does not loop through every page on each visit. - Errors show a message, not a blank page: try
private_anythingandghost_anythingwith your test key (Sandbox).
FAQ
Can I use the Klupt API with Lovable, Bolt, Replit or v0?
Yes. Paste the prompt above, keep the key in the tool's secrets, and let the tool write a small server function (a Supabase Edge Function in Lovable or Bolt, a backend in Replit, a route handler in v0) that calls the API.
Why can't my page call the API directly?
It can technically, because the API allows browser requests for quick tests. But the key would be visible to every visitor, who could then spend your credits. Live keys sent from a web page get a meta.warning for that reason. Use a test key for in-browser experiments and a server function for real use.
Which file should I give my AI tool?
https://api.klupt.io/llms-full.txt for a chat, https://api.klupt.io/AGENTS.md for a repository, https://api.klupt.io/openapi.json for a code generator. The MCP server is for asking an assistant questions about Instagram accounts directly, not for building an app.
Is there an SDK?
Not yet. The API is plain HTTPS and JSON with one header, so a few lines of fetch or requests are enough, and the OpenAPI spec generates a typed client in any language.
Updated 2026-11-30 · Markdown · Questions? [email protected]
