ipfs
0.27.3

Intro

Installable via npm install --save ipfs, it can also be used directly in the browser.

Download

The source is available for download from GitHub. Alternatively, you can install using npm:

$ npm install --save ipfs

You can then require() ipfs as normal:

const ipfs = require('ipfs')

In the Browser

Ipfs should work in any ES2015 environment out of the box.

Usage:

<script type="text/javascript" src="index.js"></script>

The portable versions of ipfs, including index.js and index.min.js, are included in the /dist folder. Ipfs can also be found on unkpkg.com under

get

Given a key, query the DHT for its best value.

Parameters

  1. key: Buffer:  
  2. callback: function (Error)?:  

Returns

(Promise | void)

put

Write a key/value pair to the DHT.

Given a key of the form /foo/bar and a value of any form, this will write that value to the DHT with that key.

Parameters

  1. key: Buffer:  
  2. value: Buffer:  
  3. callback: function (Error)?:  

Returns

(Promise | void)

findprovs

Find peers in the DHT that can provide a specific value, given a key.

Parameters

  1. key: CID:  
    They key to find providers for.
  2. callback: function (Error, Array<PeerInfo>)?:  

Returns

(Promise<PeerInfo> | void)

findpeer

Query the DHT for all multiaddresses associated with a PeerId.

Parameters

  1. peer: PeerId:  
    The id of the peer to search for.
  2. callback: function (Error, Array<Multiaddr>)?:  

Returns

(Promise<Array<Multiaddr>> | void)

provide

Announce to the network that we are providing given values.

Parameters

  1. keys: (CID | Array<CID>):  
    The keys that should be announced.
  2. options: Object (={}):  
  3. options.recursive: bool (=false):  
    Provide not only the given object but also all objects linked from it.
  4. callback: function (Error)?:  

Returns

(Promise | void)

query

Find the closest peers to a given PeerId, by querying the DHT.

Parameters

  1. peer: PeerId:  
    The PeerId to run the query agains.
  2. callback: function (Error, Array<PeerId>)?:  

Returns

(Promise<Array<PeerId>> | void)