Skip to content

Latest commit

 

History

History
94 lines (72 loc) · 1.49 KB

ipfs.md

File metadata and controls

94 lines (72 loc) · 1.49 KB

IpfsAPI

The IpfsAPI allows you to interact with IPFS through Fileroom.

Usage

Import the IpfsAPI from the client:

const { ipfs } = client;

Methods

status(cid)

Check the pinning status of a CID.

const status = await ipfs.status('Qmabc123...');

Returns:

{
  "peername": "peer name",
  "status": "pinned", 
  "ipfs_peer_id": "peer id",
  "ipfs_peer_addresses": [
    "/ip4/127.0.0.1/tcp/4001/ipfs/QmPeerId"
  ],
  "timestamp": "ISO date string",
  "error": "",
  "attempt_count": 1,
  "priority_pin": true,
  "metadata": {},
  "created": "ISO date string"
}

get(cid, options?)

Fetch a file from the gateway by CID.

const stream = await ipfs.get('Qmabc123...');
Option Type Description
origin string Gateway origin, defaults to Fileroom gateway
size string Preview size string (e.g. '200x200')

Returns: Promise<Stream>

pin(cid, options?)

Pin a CID to Fileroom's IPFS cluster.

await ipfs.pin('Qmabc123...');
Option Type Description
resize string[] Array of preview size strings to generate on pinning

Returns:

{
  "message": "pinned successfully",
  "result": {
    "docId": "doc id",
    "cid": "pinned cid",
    "previews": [
      {
        "cid": "preview cid 1",
        "size": "200x200" 
      },
      {
        "cid": "preview cid 2",
        "size": "400x400"
      }
    ]
  },
  "listenTo": {
    "wsUrl": "ws url",
    "event": "pinning_progress"
  }
}