Core database and replication for cabal.
Clone or download
nikolaiwarner Merge pull request #33 from cabal-club/max-feeds-option
Add an option to set the maxFeeds option of hypercore-protocol
Latest commit d408b9b Dec 19, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
test green specs & evergreen deps for kappa refactor Aug 27, 2018
views Merge branch 'feature/fix_topics_get' Nov 18, 2018
.gitignore add ignore rule for vim cache files Nov 6, 2018
.travis.yml 1.0.0 May 16, 2018
LICENSE 1.0.0 May 16, 2018 update readme Sep 20, 2018
index.js Add an option to set the maxFeeds option of hypercore-protocol Dec 13, 2018
package.json 4.0.0 Nov 16, 2018
swarm.js fix: reliable key exchange Nov 11, 2018


Core database, replication, and chat APIs for cabal.


npm install cabal-core


var Cabal = require('cabal-node')

var cabal = Cabal([storage][, key][, opts])

Create a cabal p2p database using storage storage, which must be either a string (filepath to directory on disk) or an instance of random-access-storage.

If this is a new database, key can be omitted and will be generated.


Returns the local user's key (as a string).

var ds = cabal.replicate()

Creates a new, live replication stream. This duplex stream can be piped into any transport expressed as a node stream (tcp, websockets, udp, utp, etc).


cabal.channels.get(function (error, channels) {})

Retrieve a list of all channel names that exist in this cabal.'add', function (channel) {})

Emitted when a new channel is added to the cabal.


var rs =, opts)

Returns a readable stream of messages (most recent first) from a channel.

Pass opts.limit to set a maximum number of messages to read.'message', fn)

Calls fn with every new message that arrives, regardless of channel., fn)

Calls fn with every new message that arrives in channel.


cabal.on('peer-added', function (key) {})

Emitted when you connect to a peer. key is a hex string of their public key.

cabal.on('peer-dropped', function (key) {})

Emitted when you lose a connection to a peer. key is a hex string of their public key.


cabal.publish(message, opts, cb)

Publish message to your feed. message must have a type field set. If not, it defaults to chat/text. In general, a message is formatted as

  type: 'chat/text',
  content: {
    text: 'hello world',
    channel: 'cabal-dev'

A timestamp field is set automatically with the current system time.

type is an unrestricted field: you can make up new message types and clients will happily ignore them until someone implements support for them. Well documented types include


  type: 'chat/text',
  content: {
    text: 'whatever the user wants to say',
    channel: 'some channel name. if it didnt exist before, it does now!'


var swarm = require('cabal-core/swarm')


Join the P2P swarm for a cabal, start connecting to peers and replicating messages.

Returns a discovery-swarm.