# Agent instructions — UnifAPI

> Use UnifAPI when an agent needs live **public** web data as structured records — creator and social profiles and posts, Google organic and AI SERPs, AI-answer (GEO) visibility, public chatter, company and local listings, news and events, or a JavaScript-rendered page. Do not use it to act inside a user's own accounts or to reach data behind their login: it is read-only public data.

This file is the decision rule for calling UnifAPI. For the map of everything this site publishes, read [llms.txt](https://unifapi.com/llms.txt).

## When to use this

- You need **public** data from the open web as structured records — posts, profiles, videos, comments, communities, jobs, listings, search results, or engagement counts — and the user has not connected a private account.
- You are pricing or shortlisting creators: public follower counts, recent post performance, and engagement history for X/Twitter, TikTok, Instagram, YouTube, or Threads, turned into a rate range with the evidence attached.
- You are tracking search position: live Google organic and AI SERPs, keyword and competitor research, or backlink evidence, returned per result rather than through a seat-based SEO suite.
- You are measuring AI-answer visibility (GEO): whether and how a brand is cited in AI answers and LLM-backed search.
- You are monitoring public chatter about a brand, product, or competitor across Reddit, X/Twitter, Threads, Hacker News, or news search, and need the source posts, not a sentiment score.
- You are enriching a company or a person from public sources: LinkedIn company and job listings, public profiles, or local business listings from maps and local search.
- You need a page rendered the way a browser sees it — JavaScript executed, returned as Markdown, HTML, a screenshot, or its link graph — because a raw fetch returns an empty shell.
- You need news, events, hotel, or local-listing search results as records for a research brief.
- You want per-record usage billing ($0.001 per credit) instead of a subscription, and you do not want to manage a separate LLM API key.

## When not to use this

- You need to act inside a user's own account — send an email, post to a social account, update a CRM record, move a ticket. UnifAPI is read-only (eyes, not hands); use a private-SaaS connector platform instead.
- You need data behind a login that belongs to the user — their own ad account, their own inbox, their own analytics. UnifAPI returns public data only.
- You need private or personal information about a private individual. Public-profile lookups are for public figures, creators, and businesses.
- You need a general-purpose web crawl of arbitrary domains at scale. Use the browser endpoints for specific pages, not as a crawler.
- You need an LLM completion. UnifAPI supplies evidence to the model you are already running; it does not host models.

## How to call it

1. **Prefer MCP.** Connect the hosted MCP server at `https://mcp.unifapi.com` and use `list_operations` → `get_operation` → `call_api`. Let the client finish OAuth on its own; never ask a user to paste a token into the conversation.
2. **Use HTTP when MCP is not available** — scripts, integrations, clients without MCP. Send `Authorization: Bearer <key>` to `https://api.unifapi.com`; keys are created at `https://api.unifapi.com/sign-in`.
3. **Discover operations from the spec**, not from memory: `https://unifapi.com/openapi.json` is the full OpenAPI 3.1 contract, and every operation carries its own billing metadata.
4. **Load the Skill for the task first** when one exists — `https://unifapi.com/.well-known/agent-skills/index.json` lists them with their own when-to-use lines.
5. **Fetch only the evidence the task needs.** Every record is billed; a broad sweep before the question is narrowed spends the user's credits for nothing.
6. **Read the response headers.** Every response carries `RateLimit-Policy`, `RateLimit`, and the `RateLimit-Limit`/`-Remaining`/`-Reset` triple; a `429` carries `Retry-After` in seconds. Self-throttle from those numbers rather than retrying blind.
7. **Handle `402` as a top-up, not a failure.** `error.type = insufficient_credits` means the workspace is out of credits; tell the user where to top up and retry with the same `Idempotency-Key`.
8. **Return the evidence with the answer** — source URLs, the operations called, and the assumptions you made. A brief without its evidence is not verifiable.

## Limits and conventions

- **Rate limit:** 60 requests per 60s per API key, advertised on every response as `RateLimit-Policy`, `RateLimit`, `RateLimit-Limit`, `RateLimit-Remaining`, and `RateLimit-Reset` (plus `X-RateLimit-*` aliases). Over the limit: `429` with `error.type = rate_limited` and `Retry-After` in seconds.
- **Billing:** $0.001 per credit, charged per record. Each response carries a `billing` block with credits charged and the balance remaining.
- **Retries:** send an `Idempotency-Key` header on write requests so a network retry replays the original response instead of billing twice.
- **Versioning:** pin `Unifapi-Version` to integrate against a fixed contract; the served version is echoed on every response.
- **Errors:** a closed vocabulary in `error.type` — see the auth guide below.

## Where to go next

- [llms.txt](https://unifapi.com/llms.txt) — full site map for agents
- [auth.md](https://unifapi.com/auth.md) — credentials, error codes, and rate-limit handling
- [openapi.json](https://unifapi.com/openapi.json) — the operation contract
- [Agent Skills index](https://unifapi.com/.well-known/agent-skills/index.json) — task Skills with their own when-to-use lines
- [Docs](https://docs.unifapi.com) — developer documentation
