# IPFS Content Fetcher via CID

> IPFS Content Fetcher via CID is a paid API for AI agents from x402.agentutility.ai, paid per call via x402, $0.005/call, status unknown (last checked 2026-09-15).

Fetches content from IPFS by CID and optional path through public gateways, returning the content as base64, plain text, or parsed JSON (up to 5 MB).

## Facts

- Endpoint: POST https://x402.agentutility.ai/ipfs
- Price: $0.005/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/ipfs-content-fetcher-via-cid-1cf5cd6e
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_la2EEWctBB7G54o-Osrjv

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 ipfs-content-fetcher-via-cid-1cf5cd6e -d '<json body>'
```

Example prompt: Can you fetch the content at IPFS CID bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi and return it as parsed JSON?

## When to prefer this

Use this endpoint when you need to resolve IPFS CIDs to their content programmatically from within an agent workflow — especially for NFT metadata, decentralized config files, or any Web3 resource whose URI starts with ipfs://. Prefer this over direct IPFS gateway calls when you need a reliable, agent-friendly API with consistent response formatting (base64/text/JSON) and a known 5 MB cap. It is settled via x402/USDC so it integrates naturally into autonomous agent payment flows without requiring API keys.

## Known failure modes

- CID not found or unpinned on available gateways — returns 404 or gateway error
- Content exceeds 5 MB hard cap — request rejected or truncated
- Invalid or malformed CID — returns parsing error
- Gateway timeout if content is slow to retrieve from the IPFS network
- Path not found within the CID's DAG — returns path resolution error
- Non-UTF-8 content requested as text — encoding error

## How this service works

Retrieves IPFS content by CID and optional path through public gateways, returning base64, text, or parsed JSON with a 5 MB hard cap. Use it as an IPFS fetch API, CID resolver, or NFT metadata fetcher.

## Output

Returns the content of the specified IPFS CID (and optional sub-path) in one of three formats: base64-encoded binary, plain UTF-8 text, or a parsed JSON object. Content is capped at 5 MB. Includes any relevant content-type metadata from the gateway response.

## 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",
    "bodyType",
    "body"
   ],
   "properties": {
    "body": {
     "required": [
      "cid"
     ],
     "properties": {
      "cid": {
       "type": "string",
       "description": "IPFS CID, CIDv0 (Qm... base58, 46 chars) or CIDv1 (bafy... base32). Required."
      },
      "path": {
       "type": "string",
       "description": "Optional sub-path inside the IPFS directory, e.g. '/index.html' or 'metadata.json'. Leading slash optional."
      },
      "output": {
       "enum": [
        "base64",
        "text",
        "json"
       ],
       "type": "string",
       "description": "How to return the content. 'base64' (default — safe for binary), 'text' (UTF-8 decode), or 'json' (UTF-8 decode + JSON.parse). Returns 424 if every gateway fails or, for 'json', if the body doesn't parse."
      },
      "max_bytes": {
       "type": "number",
       "description": "Maximum response size in bytes. Default 1000000 (1 MB). Hard-capped at 5000000 (5 MB)."
      }
     }
    },
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "POST"
     ],
     "type": "string"
    },
    "bodyType": {
     "enum": [
      "json",
      "form-data",
      "text"
     ],
     "type": "string"
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object",
     "properties": {
      "cid": {
       "type": "string"
      },
      "source": {
       "type": "string"
      },
      "content": {
       "type": "string"
      },
      "size_bytes": {
       "type": "integer"
      },
      "content_type": {
       "type": "string"
      },
      "gateway_used": {
       "type": "string"
      }
     }
    }
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "cid": "bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi",
  "source": "ipfs",
  "content": "Hello World\n",
  "size_bytes": 12,
  "content_type": "text/plain",
  "gateway_used": "https://cloudflare-ipfs.com"
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/ipfs-content-fetcher-via-cid-1cf5cd6e/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402.agentutility.ai](https://www.zero.xyz/host/x402.agentutility.ai/llms.txt)
