# IPFS Content Fetcher via Fallback Gateway Chain

> IPFS Content Fetcher via Fallback Gateway Chain is a paid API for AI agents from x402-deployer.x402-deployer.workers.dev, paid per call via x402, $0.005/call, status unknown (last checked 2026-09-14).

Resolves an IPFS CID (v0 or v1) with optional sub-path through a fallback chain of public gateways and returns the content as base64, text, or parsed JSON (max 5 MB).

## Facts

- Endpoint: POST https://x402-deployer.x402-deployer.workers.dev/ipfs-fetch
- Price: $0.005/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/x402-deployer-x402-deployer-workers-dev-ce774ff9
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_uZLocxEx3xEexwEnyg9Ug

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 x402-deployer-x402-deployer-workers-dev-ce774ff9 -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 without running a local IPFS node, especially for NFT metadata, Web3 content, or pinned files. The fallback gateway chain (Cloudflare → ipfs.io → dweb.link) provides resilience over a single-gateway approach. Prefer over manual gateway calls when you want automatic fallback, size-safety enforcement, and structured output (base64/text/JSON) in one call.

## Known failure modes

- CID not found on any gateway in the fallback chain — 404 or timeout
- Content exceeds 5 MB hard cap — rejected after HEAD pre-flight
- Invalid or malformed CID format — validation error
- All gateways unreachable or rate-limited — upstream error
- Sub-path does not exist within the resolved content — path error

## How this service works

IPFS fetch / IPFS gateway / Web3 storage retrieval / NFT metadata fetcher / Filecoin gateway / decentralized content / pinned-content reader. Resolves a CID (CIDv0 Qm... or CIDv1 bafy...) and optional sub-path through a fallback chain of public gateways (cloudflare-ipfs.com to ipfs.io to dweb.link) and returns the content as base64 / text / parsed JSON. Hard cap 5 MB. HEAD pre-flight + streaming size cap so oversized files are rejected before they're fully downloaded. No API key required.

## Output

Returns the resolved content of the IPFS CID as base64, plain text, or parsed JSON depending on the detected content type. Also includes content size and metadata. Files exceeding 5 MB are rejected before full download via HEAD pre-flight check.

## 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"
      }
     }
    }
   }
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/x402-deployer-x402-deployer-workers-dev-ce774ff9/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402-deployer.x402-deployer.workers.dev](https://www.zero.xyz/host/x402-deployer.x402-deployer.workers.dev/llms.txt)
