# Busca para Agentes > Hosted API that gives any Next.js site a standard `/.well-known/search` endpoint (open "Search for Agents" contract): research and shopping AI agents query the site and get Markdown chunks instead of crawling pages. This API is for coding agents that install and operate it. Research/shopping agents should call the site origin at `/.well-known/search`, not this API. ## Install (coding agent, 1 command) ``` npx busca-agentes init --origin https://example.com --email owner@example.com ``` Or MCP: `npx -y @busca-agentes/mcp` (tools: create_account → register_site → install_nextjs → index_site → get_usage → create_credit_link). MCP Registry name: com.busca-agentes/mcp. ## Endpoints (base https://api.busca-agentes.com) - POST /v1/accounts {email} → {id, adminKey} (409 if email exists). No human needed. - POST /v1/sites (Bearer adminKey) {origin, sitemapUrl?} → {id, apiKey, env} - GET /v1/sites (Bearer adminKey) - POST /v1/sites/{id}/index (Bearer adminKey) → crawls sitemap.xml, embeds pages - GET /v1/sites/{id}/usage (Bearer adminKey) - GET|HEAD|QUERY /v1/search (Bearer site apiKey) → Markdown; add ?format=json for hits - POST /v1/billing/checkout (Bearer adminKey) {queries?, method?} → Stripe Checkout URL in USD (default). method=pix or method=mercadopago for Brazil (BRL). 503 if billing is not configured. - POST /v1/billing/stripe/webhook — Stripe signature-verified credit - GET /v1/health ## Search contract (on the customer site) GET https://{site}/.well-known/search?q={query} QUERY https://{site}/.well-known/search with text/plain body or JSON {"q": "..."} Response: text/markdown. Missing q → 400. Headers: Allow: GET, HEAD, QUERY; Accept-Query: text/plain, application/json. Discovery: . Live demo: https://busca-agentes.com/.well-known/search?q=quanto%20custa%20o%20geisha ## Pricing 1,000 free queries per site per UTC month, then prepaid credit at US$ 0.75 per 1,000 queries (Stripe Checkout, USD). HTTP 429 when exhausted. Brazil: Pix / Mercado Pago in BRL is an option (`method: "pix"` or `"mercadopago"`). ## More - Full docs: https://api.busca-agentes.com/llms-full.txt - OpenAPI: https://api.busca-agentes.com/openapi.yaml - MCP server card: https://api.busca-agentes.com/.well-known/mcp.json - npm: busca-agentes, @busca-agentes/next, @busca-agentes/mcp --- # Full reference ## Quick start with curl (no human, no dashboard) ```bash API=https://api.busca-agentes.com # 1. Account (store adminKey; it is shown once) curl -s -X POST $API/v1/accounts -H 'content-type: application/json' -d '{"email":"owner@example.com"}' # 2. Register the site curl -s -X POST $API/v1/sites -H "authorization: Bearer $ADMIN_KEY" -H 'content-type: application/json' \ -d '{"origin":"https://example.com","sitemapUrl":"https://example.com/sitemap.xml"}' # 3. Index curl -s -X POST $API/v1/sites/$SITE_ID/index -H "authorization: Bearer $ADMIN_KEY" # 4. Search through the API (or through the site's /.well-known/search once installed) curl -s -G $API/v1/search -H "authorization: Bearer $SITE_API_KEY" --data-urlencode "q=preço" curl -s -X QUERY $API/v1/search -H "authorization: Bearer $SITE_API_KEY" -H 'content-type: text/plain' --data 'preço' ``` ## Next.js install (what `npx busca-agentes init` writes) ```ts // app/.well-known/search/route.ts import { createSearchHandlers } from "@busca-agentes/next"; export const { GET, HEAD, QUERY, OPTIONS } = createSearchHandlers(); // app/layout.tsx import { agentSearchMetadata } from "@busca-agentes/next"; export const metadata = { ...agentSearchMetadata({ origin: "https://example.com" }) }; // proxy.ts (Next.js 16: route handlers do not dispatch HTTP QUERY yet) import { createAgentSearchProxy, agentSearchProxyConfig } from "@busca-agentes/next"; const agentSearch = createAgentSearchProxy(); export async function proxy(request: Request) { return agentSearch(request); } export const config = agentSearchProxyConfig; ``` Environment variables on the site: BUSCA_AGENTES_API_KEY (required), BUSCA_AGENTES_SITE_ID, BUSCA_AGENTES_SITE_ORIGIN, BUSCA_AGENTES_API_URL (default https://api.busca-agentes.com). ## Response format ``` # Search results for: "{query}" ## {source} (score: 1.000) {chunk text} --- ``` Results are retrieved page chunks (hybrid: pgvector embeddings openai/text-embedding-3-small + Postgres full-text), not generated answers. Default threshold 0.4, up to 10 results. ## Errors 400 missing q · 401 bad/missing key · 409 account exists · 415 unsupported QUERY content type · 429 quota exhausted · 503 billing not configured · 502 payment provider error. ## Billing POST /v1/billing/checkout with `{"method":"stripe"}` (or omit method for non-BR accounts) returns a Stripe Checkout URL in USD at US$ 0.75 per 1,000 queries. The coding agent must hand this URL to the human site owner and never pay it. Credit is added after Stripe confirms the payment: the webhook at `/v1/billing/stripe/webhook` verifies the Stripe signature, re-fetches the Checkout Session or PaymentIntent, and credits only if the charge is paid in USD for at least 90% of the expected amount. Duplicate events are ignored. Brazil option: `{"method":"pix"}` creates a Pix charge in BRL; `{"method":"mercadopago"}` opens Mercado Pago Checkout Pro (card, balance, Pix). Credit is added after Mercado Pago confirms the payment with the Mercado Pago API. ## MCP ```json { "mcpServers": { "busca-agentes": { "command": "npx", "args": ["-y", "@busca-agentes/mcp"] } } } ``` Tools: create_account(email), register_site(origin, sitemapUrl?), install_nextjs(cwd, origin), index_site(siteId), get_usage(siteId), create_credit_link(queries?, method?).