0.0.20 • Published 12 months ago

@zinde/ipfs-fetch v0.0.20

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

@zinde/ipfs-fetch

⚡ Fetch IPFS contents through the fastest gateway by sending requests to multiple gateways simultaneously. Try on CodeSandbox.

Installation

Using yarn:
yarn add @zinde/ipfs-fetch
Or via npm:
npm install @zinde/ipfs-fetch --save
Or via pnpm:
pnpm add @zinde/ipfs-fetch

Examples

Basic fetch
import { ipfsFetch } from '@zinde/ipfs-fetch'

ipfsFetch('ipfs://bafkreic5k3zvarbsondfrowy7kpbj6xo7cj25hobksgileqbbupjvvmkoq')
Custom gateways
import { ipfsFetch, IpfsGatewayTemplate } from '@zinde/ipfs-fetch'

// Default gateways: https://github.com/zinde-social/zinde-ipfs-utils/blob/main/packages/ipfs-fetch/src/constant.ts
const gateways: IpfsGatewayTemplate[] = [
  'https://{cid}.ipfs.cf-ipfs.com/{pathToResource}',
  'https://ipfs.io/ipfs/{cid}{pathToResource}',
]

ipfsFetch('ipfs://bafkreic5k3zvarbsondfrowy7kpbj6xo7cj25hobksgileqbbupjvvmkoq', {
  gateways,
})