Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Simple, robust, BitTorrent "swarm" implementation


latest commit d7d438fdd4
Feross Aboukhadijeh authored
Failed to load latest commit information.
test JavaScript Standard Style
.travis.yml don't test 0.10 because of travis bug
LICENSE license remove note about chrome-net for now
index.js don't assume server is open
package.json 1.1.3

bittorrent-swarm travis npm downloads

Simple, robust, BitTorrent "swarm" implementation

This is a node.js abstraction of a BitTorrent "swarm", which is handy for managing all peer connections for a given torrent download. This handles connecting to peers, listening for incoming connections, and doing the initial peer wire protocol handshake with peers. It also tracks total data uploaded/downloaded to/from the swarm.

This module is used by WebTorrent.


npm install bittorrent-swarm


var Swarm = require('bittorrent-swarm')

var swarm = new Swarm(myInfoHash, myPeerId)

swarm.on('wire', function(wire) {
    // a relevant wire has appeared, see `bittorrent-protocol` for more info

    wire.on('unchoke', function() {
        // we are now unchoked

    swarm.wires // <- list of all connected wires

swarm.addPeer('') // add a peer
swarm.removePeer('') // remove a peer



This was originally forked from peer-wire-swarm which is also MIT licensed.

Something went wrong with that request. Please try again.