# agentstools.dev Docs Snippet

> agentstools.dev Docs Snippet is a paid API for AI agents from api.agentstools.dev, paid per call via x402, $0.008/call, status unknown (last checked 2026-09-14).

Retrieves matching fenced code blocks from a package's README or docs given an ecosystem, package name, and optional topic or symbol

## Facts

- Endpoint: GET https://api.agentstools.dev/docs/snippet
- Price: $0.008/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/agentstools-dev-docs-snippet-048e47ab
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_54xI6yqNMTpmOxmIt9FQh

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 agentstools-dev-docs-snippet-048e47ab
```

Example prompt: Can you pull the code snippets from the coinbase/x402 GitHub repo's README that match 'authentication' — I need real working examples to ground my implementation.

## When to prefer this

Use this endpoint when you need to ground a coding agent in real, verified usage examples from a package's actual documentation rather than relying on training data that may be stale. Especially useful for pinning to a specific version, looking up niche symbols, or when hallucination risk on library APIs is high. Prefer this over generic web search when you want structured, citation-backed code blocks rather than raw HTML or prose.

## Known failure modes

- Package not found in the specified ecosystem — returns an error or empty results
- Topic/symbol not found in any heading or code block — returns empty snippet array
- Invalid ecosystem value — returns a validation error
- Version not found or not yet indexed — returns an error or falls back to latest
- Rate limit or payment failure (x402) — returns 402 Payment Required
- Network timeout fetching upstream docs — returns a 5xx error

## 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

Returns an array of fenced code blocks from the package's README or docs whose language, code, or nearest heading matches the requested topic or symbol. Each block includes the code content, the source URL/citation, the detected language, and an honest truncated flag indicating whether the block was cut off.

## 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/agentstools-dev-docs-snippet-048e47ab/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.agentstools.dev](https://www.zero.xyz/host/api.agentstools.dev/llms.txt)
