Registry / storage / chunk-fetch

chunk-fetch

JSON →
library25.0.4jsnpmunverified

chunk-fetch provides a browser-compatible fetch() API for HTTP requests to IPFS, enabling interaction with IPFS content using familiar fetch patterns. The library supports HEAD, GET, POST, and DELETE methods with IPFS-style URLs (ipfs://). Hostname can be '_' to ignore hostname, or a CID for direct content retrieval. Additional headers like X-Copy, X-Timer, and X-Opt control behavior. Version 25.0.4 is current. It differentiates from other IPFS HTTP clients by mimicking the Web Fetch API exactly, reducing learning curve for developers already familiar with fetch. Release cadence is irregular; maintenance is active with recent updates.

npm install chunk-fetch
INSTALL
IMPORT
SIG · CHUNK-FETCH
C
chunk-fetch
storagejavascriptv25.0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import chunkFetch from 'chunk-fetch'
const chunkFetch = require('chunk-fetch')
Package is ESM-only since v25; CJS require will fail.
chunkFetch
import { chunkFetch } from 'chunk-fetch'
Recommended named import; default export also available.
types
import type { FetchOptions } from 'chunk-fetch'
import { FetchOptions } from 'chunk-fetch'
FetchOptions is a TypeScript type, not a runtime value.

Shows basic GET request to IPFS using chunk-fetch, with timeout header and response handling.

import chunkFetch from 'chunk-fetch'; const response = await chunkFetch('ipfs://_/path/to/data', { method: 'GET', headers: { 'X-Timer': '5000' } }); const data = await response.text(); console.log(data);
Debug
Known issues
breakingESM-only: require() will throw error
fix
Use import or dynamic import().
affects: >=25.0.0
gotchaHostname '_' is required for path queries; omitting it results in incorrect URL parsing
fix
Always use ipfs://_/path instead of ipfs:///path
affects: all
gotchaDELETE method returns body content, not just status
fix
Handle response as text or json after delete.
affects: all
deprecatedX-Opt header format may change in future versions
fix
Watch changelog for updates.
affects: all
gotchaPOST with X-Opt requires stringified JSON
fix
Always JSON.stringify() options object before setting header.
affects: all
Errors
Common errors & fixes
TypeError: chunkFetch is not a function
Attempted to require() ESM module in CommonJS environment
fix
Switch to import statement or use dynamic import('chunk-fetch').
Error: Invalid URL: ipfs:///path
Missing hostname part in IPFS URL
fix
Use ipfs://_/path instead of ipfs:///path
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
X-Opt header value is not valid JSON
fix
Ensure X-Opt is stringified: JSON.stringify(options)
Upgrade
Version history
25.0.4latest on npm
Audit
Dependencies
ipfs-http-clientrequiredUsed internally to make actual calls to IPFS nodes
Agent activity
22 hits · last 30 days
node
18
Bingbot
1
Resources
chunk-fetch — npm install chunk-fetch · libregistry