# docs-snippet

> docs-snippet is a paid API for AI agents from payai.agentstools.dev, paid per call via x402, $0.008/call, status unknown (last checked 2026-10-11).

Retrieves matching fenced code blocks from a package's README or docs for a given topic or symbol, with source citations and truncation flags.

## Facts

- Endpoint: GET https://payai.agentstools.dev/docs/snippet?utm_source=zero.xyz
- Price: $0.008/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-11
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/docs-snippet-b9ad54e1
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_JcUrKOfdolE-fcGDp1oi5

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability docs-snippet-b9ad54e1
```

Example prompt: Can you grab a working code snippet from the npm package axios docs that shows how to set up request interceptors? I want a real example I can paste into my project.

## When to prefer this

Use this endpoint when a coding agent needs to ground itself in real, cited usage examples from a package's actual README or documentation rather than hallucinating syntax. It is ideal when you know the package name and a specific topic or symbol and need working code to paste or adapt, especially across npm, pypi, crates, and GitHub repos. Prefer this over general web search when you want structured, language-tagged code blocks with source citations and truncation honesty signals.

## Known failure modes

- Package not found in the specified ecosystem — returns empty results or 404-like response
- Topic or symbol does not match any heading or code block in the docs — returns empty snippet list
- Requested version does not exist or is not indexed — falls back to latest or returns error
- README/docs are not structured enough to extract fenced code blocks — returns empty list
- Ecosystem alias not recognized if misspelled beyond supported aliases

## How this service works

Working code snippets for a library, matched to a topic. Give an ecosystem, package name and a topic or symbol and get the fenced code blocks from the README or docs whose language, code or nearest heading matches, each with a source citation and an honest truncated flag. Ideal for grounding a coding agent in real usage examples.

## Output

A list of fenced code blocks extracted from the package's README or documentation, each including the code content, the programming language, the nearest heading or section it came from, a source URL or citation, and a boolean flag indicating if the block was truncated.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET",
      "HEAD",
      "DELETE"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "required": [
      "name",
      "ecosystem"
     ],
     "properties": {
      "name": {
       "type": "string",
       "description": "Package name; for github pass owner/repo such as coinbase/x402. npm scoped names @scope/name are allowed."
      },
      "topic": {
       "type": "string",
       "description": "Optional topic or symbol; matched against the README/llms.txt markdown headings, such as authentication or useEffect."
      },
      "symbol": {
       "type": "string",
       "description": "Optional symbol name to match, an alias for topic."
      },
      "version": {
       "type": "string",
       "description": "Optional exact version to pin, such as 2.31.0; default is latest."
      },
      "ecosystem": {
       "enum": [
        "npm",
        "pypi",
        "crates",
        "github"
       ],
       "type": "string",
       "description": "Package ecosystem. Aliases accepted: pip and python map to pypi; cargo and rust map to crates; node maps to npm; gh maps to github."
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object"
    }
   }
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/docs-snippet-b9ad54e1/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from payai.agentstools.dev](https://www.zero.xyz/host/payai.agentstools.dev/llms.txt)
