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
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.
Returns
(Promise | void)
findprovs
Find peers in the DHT that can provide a specific value, given a key.
Returns
(Promise<PeerInfo> | void)
findpeer
Query the DHT for all multiaddresses associated with a PeerId.
Parameters
peer: PeerId:The id of the peer to search for.
provide
Announce to the network that we are providing given values.
Parameters
Returns
(Promise | void)
query
Find the closest peers to a given PeerId, by querying the DHT.
Parameters
peer: PeerId:ThePeerIdto run the query agains.
version
If the repo has been initialized, report the current version. Otherwise report the version that would be initialized.
Returns
parseIpfsPath
Break an ipfs-path down into it's hash and an array of links.
examples: b58Hash -> { hash: 'b58Hash', links: [] } b58Hash/mercury/venus -> { hash: 'b58Hash', links: ['mercury', 'venus']} /ipfs/b58Hash/links/by/name -> { hash: 'b58Hash', links: ['links', 'by', 'name'] }
Parameters
ipfsPath: String:An ipfs-path
Returns
Object { hash: base58 string, links:
[
string
]
, ?err: Error }
Throws
any on an invalid @param ipfsPath
resolvePath
Resolve various styles of an ipfs-path to the hash of the target node. Follows links in the path.
Accepts formats:
-
/link/to/venus - /ipfs/
/link/to/pluto - multihash Buffer
- Arrays of the above
Parameters
objectAPI: IPFS:The IPFS object apicallback: Function<err, res>:res is Array<Buffer(hash)> if no callback is passed, returns a Promise
Returns
(Promise | void)