1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
|
# ![WebTorrent](img/wordmark.png)
[![Build Status][webtorrent-ti]][webtorrent-tu]
[![NPM Version][webtorrent-ni]][webtorrent-nu]
[![NPM Downloads][webtorrent-downloads-image]][webtorrent-downloads-url]
[![Gratipay][webtorrent-gratipay-image]][webtorrent-gratipay-url]
### WebTorrent – Streaming torrent client for node & the browser
WebTorrent is a streaming torrent client that works in node.js and the browser. **YEP,
THAT'S RIGHT. The browser.** It's written completely in JavaScript – the language of the
web – so the same code works in both runtimes.
In browsers, WebTorrent uses **WebRTC** (data channels) for peer-to-peer transport. It can
be used **without** browser plugins, extensions, or installations. It's Just
JavaScript™.
Simply include the `webtorrent.min.js` script on your page to start fetching files over
WebRTC using the BitTorrent protocol. See [code examples](#usage) below.
To make BitTorrent work over WebRTC (which is the only p2p transport that works on the
web) we made some protocol changes. Currently, WebTorrent clients can only connect to
other WebTorrent clients.
We hope established torrent clients (uTorrent, Transmission, Vuze, etc.) will add support
for WebRTC and the WebTorrent extensions so they can swarm with peers from both the normal
*and* web networks.
![Network](img/network.png)
> Warning: This is pre-alpha software. **Watch/star to follow along with progress.**
[![Sauce Test Status][webtorrent-sauce-image]][webtorrent-sauce-url]
### Features
- **Torrent client for node.js & the browser** (same npm module!)
- **Insanely fast**
- **Streaming video** to many devices (including AirPlay, Chromecast, and VLC player)
- Download **multiple torrents** simultaneously, efficiently
- **Pure Javascript** (no native dependencies)
- Exposes files as **streams** (and fetches pieces on-demand before torrent is finished
- Fetches data from the network on-demand, so streaming and seeking are supported
- Seamlessly switches between sequential and rarest-first piece selection strategy
- Supports advanced torrent client features
- **magnet uri** support via **[ut_metadata](https://github.com/feross/ut_metadata)**
- **peer discovery** via **[dht](https://github.com/feross/bittorrent-dht)**,
**[tracker](https://github.com/feross/bittorrent-tracker)**, and
**[ut_pex](https://github.com/fisch0920/ut_pex)**
- **[protocol extension api](https://github.com/feross/bittorrent-protocol#extension-api)**
for adding new extensions
- **Comprehensive test suite** (completely offline, so it's reliable and fast)
#### Browser-specific features
- Uses **WebRTC data channels** for lightweight peer-to-peer communication (no plugins)
- **No silos.** WebTorrent is a P2P network for the **entire web.** WebTorrent clients
running on one domain can connect to clients on any other domain.
- Stream video torrents into a `<video>` tag (`webm (vp8, vp9)` or `mp4 (h.264)`)
### Ways to help
- **Join us in IRC** on freenode at `#webtorrent` if you want to help with development, or
you just want to hang out with some cool mad science hackers :)
- **[Create a new issue](https://github.com/feross/webtorrent/issues/new)** to report bugs
- **[Fix an issue](https://github.com/feross/webtorrent/issues?state=open)**. Note:
WebTorrent is an [OPEN Open Source Project](CONTRIBUTING.md)!
- **Donate bitcoin** if you believe in the vision and wish to support the project.
*1B6aystcqu8fd6ejzpmMFMPRqH9b86iiwh* or
**[Coinbase](https://coinbase.com/checkouts/7c683397e33166651dedfebee6fb0f96)**.
### Install
With [npm](https://npmjs.org/), run:
```bash
npm install webtorrent -g
```
### Usage
WebTorrent is the first BitTorrent client that works in the browser, using open web
standards (no plugins, just HTML5 and WebRTC)!
It's easy to get started!
#### In the browser
##### Download a file
Downloading a file is simple:
```js
var WebTorrent = require('webtorrent')
var concat = require('concat-stream')
var client = new WebTorrent()
client.download(magnet_uri, function (torrent) {
// Got torrent metadata!
console.log('Torrent info hash:', torrent.infoHash)
torrent.files.forEach(function (file) {
// Get the file data as a Buffer (Uint8Array typed array)
file.createReadStream().pipe(concat(function (buf) {
// Append a link to download the file
var a = document.createElement('a')
a.download = file.name
a.href = URL.createObjectURL(new Blob([ buf ]))
a.textContent = 'download ' + file.name
document.body.appendChild(a)
}))
})
}
```
##### Seed a file
Seeding a file is simple, too:
```js
var dragDrop = require('drag-drop/buffer')
var WebTorrent = require('webtorrent')
var client = new WebTorrent()
// When user drops files on the browser, create a new torrent and start seeding it!
dragDrop('body', function (files) {
client.seed(files, function onTorrent (torrent) {
// Client is seeding the file!
console.log('Torrent info hash:', torrent.infoHash)
})
})
```
##### Browserify
WebTorrent works great with [browserify](http://browserify.org/), an npm module that let's
you use [node](http://nodejs.org/)-style require() to organize your browser code and load modules installed by [npm](https://npmjs.org/) (as seen in the previous examples).
WebTorrent is also available as a standalone script
([`webtorrent.min.js`](webtorrent.min.js)) which exposes `WebTorrent` on the `window`
object, so it can be used with just a script tag:
```html
<script src="webtorrent.min.js"></script>
```
#### In node.js
WebTorrent also works in node.js, using the *same npm module!* It's mad science!
#### As a command line app
WebTorrent is available as a command line app Here's how to use it:
```bash
$ npm install webtorrent -g
$ webtorrent --help
```
To download a torrent:
```bash
$ webtorrent magnet_uri
$ webtorrent /path/to/file.torrent
```
To stream a torrent to a device like **AirPlay** or **Chromecast**, just pass a flag:
```bash
$ webtorrent magnet_uri --airplay
```
There are many supported streaming options:
```bash
--airplay stream to Apple TV (AirPlay)
--chromecast stream to Chromecast
--mplayer stream to MPlayer
--mpv stream to MPV
--omx [jack] stream to omx (jack=local|hdmi)
--vlc stream to VLC
--xbmc stream to XBMC
```
### WebTorrent in production
- **[Instant](http://instant.io)** – Secure, anonymous, streaming file transfer [[code](https://github.com/feross/instant.io)]
- Your app here! (send a PR or open an issue with the URL to your app)
### API
This API should work exactly the same in node and the browser. Open an issue if this is
not the case.
#### `client = new WebTorrent([opts])`
Create a new `WebTorrent` instance.
If `opts` is specified, then the default options (shown below) will be overridden.
``` js
{
dht: true, // Whether or not to enable DHT
maxPeers: 100, // Max number of peers to connect to (per torrent)
nodeId: '', // DHT protocol node ID (otherwise, randomly generated)
peerId: '', // Wire protocol peer ID (otherwise, randomly generated)
storage: function // custom storage engine, or false for in-memory engine
tracker: true, // Whether or not to enable trackers
verify: true, // Verify previously stored data before starting
}
```
#### `client.add(torrentId, [opts], [function ontorrent (torrent) {}])`
Start downloading a new torrent. Aliased as `client.download`.
`torrentId` can be one of:
- magnet uri (utf8 string)
- torrent file (buffer)
- info hash (hex string or buffer)
- parsed torrent (from [parse-torrent](https://github.com/feross/parse-torrent))
- http/https url to a torrent file (string)
- filesystem path to a torrent file (string)
If `ontorrent` is specified, then it will be called when **this** torrent is ready to be
used (i.e. metadata is available). Note: this is distinct from the 'torrent' event which
will fire for **all** torrents.
If you want access to the torrent object immediately in order to listen to events as the
metadata is fetched from the network, then use the return value of `client.add`. If you
just want the file data, then use `ontorrent` or the 'torrent' event.
#### `client.seed(input, [opts], [function onseed (torrent) {}])`
Start seeding a new torrent.
`input` can be any of the following:
- path to the file or folder on filesystem (string)
- W3C [File](https://developer.mozilla.org/en-US/docs/Web/API/File) object (from an `<input>` or drag and drop)
- W3C [FileList](https://developer.mozilla.org/en-US/docs/Web/API/FileList) object (basically an array of `File` objects)
- Array of `File` objects
If `opts` is specified, it should contain the following types of options:
- options for [create-torrent](https://github.com/feross/create-torrent#createtorrentinput-opts-function-callback-err-torrent-) (to allow configuration of the .torrent file that is created)
- options for `client.add` (see above)
If `onseed` is specified, it will be called when the client has begun seeding the file.
#### `client.on('torrent', function (torrent) {})`
Emitted when a torrent is ready to be used (i.e. metadata is available and storage is
ready). See the torrent section for more info on what methods a `torrent` has.
#### `client.remove(torrentId, [function callback (err) {}])`
Remove a torrent from the client. Destroy all connections to peers and delete all saved
file data. If `callback` is specified, it will be called when file data is removed.
#### `client.destroy()`
Destroy the client, including all torrents and connections to peers.
#### `client.listen([port], function () {})`
Listen for incoming peers on the specified port. Port defaults to `6881`
#### `client.torrents[...]`
An array of all torrents in the client.
#### `client.get(torrentId)`
Returns the torrent with the given `torrentId`. Convenience method. Easier than
searching through the `client.torrents` array.
#### `client.ratio`
Seed ratio for all torrents in the client.
### torrent api
#### `torrent.files[...]`
An array of all files in the torrent. See the file section for more info on what methods
the file has.
#### `torrent.swarm`
The attached [bittorrent-swarm](https://github.com/feross/bittorrent-swarm) instance.
#### `torrent.remove()`
Alias for `client.remove(torrent)`.
#### `torrent.addPeer(addr)`
Adds a peer to the underlying [bittorrent-swarm](https://github.com/feross/bittorrent-swarm) instance.
#### `torrent.select(start, end, [priority], [notify])`
Selects a range of pieces to prioritize starting with `start` and ending with `end` (both inclusive)
at the given `priority`. `notify` is an optional callback to be called when the selection is updated
with new data.
#### `torrent.deselect(start, end, priority)`
Deprioritizes a range of previously selected pieces.
#### `torrent.critical(start, end)`
Marks a range of pieces as critical priority to be downloaded ASAP. From `start` to `end`
(both inclusive).
### file api
#### `file.name`
File name, as specified by the torrent. *Example: 'some-filename.txt'*
#### `file.path`
File path, as specified by the torrent. *Example: 'some-folder/some-filename.txt'*
#### `file.length`
File length (in bytes), as specified by the torrent. *Example: 12345*
#### `file.select()`
Selects the file to be downloaded, but at a lower priority than files with streams.
Useful if you know you need the file at a later stage.
#### `file.deselect()`
Deselects the file, which means it won't be downloaded unless someone creates a stream
for it.
#### `stream = file.createReadStream([opts])`
Create a [readable stream](http://nodejs.org/api/stream.html#stream_class_stream_readable)
to the file. Pieces needed by the stream will be prioritized highly and fetched from the
swarm first.
You can pass `opts` to stream only a slice of a file.
``` js
{
start: startByte,
end: endByte
}
```
Both `start` and `end` are inclusive.
### Modules
Most of the active development is happening inside of small npm modules which are used by WebTorrent.
#### The Node Way™
> "When applications are done well, they are just the really application-specific, brackish residue that can't be so easily abstracted away. All the nice, reusable components sublimate away onto github and npm where everybody can collaborate to advance the commons." — substack from ["how I write modules"](http://substack.net/how_I_write_modules)
![node.js is shiny](http://feross.net/x/node2.gif)
#### Modules
These are the modules I am writing to make WebTorrent work:
| module | tests | version | description |
|---|---|---|---|
| **[webtorrent][webtorrent]** | [![][webtorrent-ti]][webtorrent-tu] | [![][webtorrent-ni]][webtorrent-nu] | **torrent client (this module)**
| [addr-to-ip-port][addr-to-ip-port] | [![][addr-to-ip-port-ti]][addr-to-ip-port-tu] | [![][addr-to-ip-port-ni]][addr-to-ip-port-nu] | cache for addr->ip:port
| [bittorrent-dht][bittorrent-dht] | [![][bittorrent-dht-ti]][bittorrent-dht-tu] | [![][bittorrent-dht-ni]][bittorrent-dht-nu] | distributed hash table client
| [bittorrent-peerid][bittorrent-peerid] | [![][bittorrent-peerid-ti]][bittorrent-peerid-tu] | [![][bittorrent-peerid-ni]][bittorrent-peerid-nu] | identify client name/version
| [bittorrent-protocol][bittorrent-protocol] | [![][bittorrent-protocol-ti]][bittorrent-protocol-tu] | [![][bittorrent-protocol-ni]][bittorrent-protocol-nu] | bittorrent protocol stream
| [bittorrent-swarm][bittorrent-swarm] | [![][bittorrent-swarm-ti]][bittorrent-swarm-tu] | [![][bittorrent-swarm-ni]][bittorrent-swarm-nu] | bittorrent connection manager
| [bittorrent-tracker][bittorrent-tracker] | [![][bittorrent-tracker-ti]][bittorrent-tracker-tu] | [![][bittorrent-tracker-ni]][bittorrent-tracker-nu] | bittorrent tracker server/client
| [buffer][buffer] | [![][buffer-ti]][buffer-tu] | [![][buffer-ni]][buffer-nu] | node buffer api for the browser
| [create-torrent][create-torrent] | [![][create-torrent-ti]][create-torrent-tu] | [![][create-torrent-ni]][create-torrent-nu] | create .torrent files
| [ip-set][ip-set] | [![][ip-set-ti]][ip-set-tu] | [![][ip-set-ni]][ip-set-nu] | efficient mutable ip set
| [load-ip-set][load-ip-set] | [![][load-ip-set-ti]][load-ip-set-tu] | [![][load-ip-set-ni]][load-ip-set-nu] | load ip sets from local/network
| [magnet-uri][magnet-uri] | [![][magnet-uri-ti]][magnet-uri-tu] | [![][magnet-uri-ni]][magnet-uri-nu] | parse magnet uris
| [parse-torrent][parse-torrent] | [![][parse-torrent-ti]][parse-torrent-tu] | [![][parse-torrent-ni]][parse-torrent-nu] | parse torrent identifiers
| [parse-torrent-file][parse-torrent-file] | [![][parse-torrent-file-ti]][parse-torrent-file-tu] | [![][parse-torrent-file-ni]][parse-torrent-file-nu] | parse .torrent files
| [simple-peer][simple-peer] | [![][simple-peer-ti]][simple-peer-tu] | [![][simple-peer-ni]][simple-peer-nu] | simpler webrtc api
| [simple-websocket][simple-websocket] | [![][simple-websocket-ti]][simple-websocket-tu] | [![][simple-websocket-ni]][simple-websocket-nu] | simpler websocket api
| [string2compact][string2compact] | [![][string2compact-ti]][string2compact-tu] | [![][string2compact-ni]][string2compact-nu] | convert 'hostname:port' to compact
| [torrent-discovery][torrent-discovery] | [![][torrent-discovery-ti]][torrent-discovery-tu] | [![][torrent-discovery-ni]][torrent-discovery-nu] | find peers via dht and tracker
| [typedarray-to-buffer][typedarray-to-buffer] | [![][typedarray-to-buffer-ti]][typedarray-to-buffer-tu] | [![][typedarray-to-buffer-ni]][typedarray-to-buffer-nu] | efficient buffer creation
| [ut_metadata][ut_metadata] | [![][ut_metadata-ti]][ut_metadata-tu] | [![][ut_metadata-ni]][ut_metadata-nu] | metadata for magnet uris **(ext)**
| [ut_pex][ut_pex] | [![][ut_pex-ti]][ut_pex-tu] | [![][ut_pex-ni]][ut_pex-nu] | peer discovery **(ext)**
| [webtorrent-swarm][webtorrent-swarm] | [![][webtorrent-swarm-ti]][webtorrent-swarm-tu] | [![][webtorrent-swarm-ni]][webtorrent-swarm-nu] | webtorrent connection management
| [webtorrent-tracker][webtorrent-tracker] | [![][webtorrent-tracker-ti]][webtorrent-tracker-tu] | [![][webtorrent-tracker-ni]][webtorrent-tracker-nu] | webtorrent tracker server/client
[webtorrent]: https://github.com/feross/webtorrent
[webtorrent-ti]: https://img.shields.io/travis/feross/webtorrent.svg?style=flat
[webtorrent-tu]: https://travis-ci.org/feross/webtorrent
[webtorrent-ni]: https://img.shields.io/npm/v/webtorrent.svg?style=flat
[webtorrent-nu]: https://npmjs.org/package/webtorrent
[webtorrent-downloads-image]: https://img.shields.io/npm/dm/webtorrent.svg?style=flat
[webtorrent-downloads-url]: https://npmjs.org/package/webtorrent
[webtorrent-gratipay-image]: https://img.shields.io/gratipay/feross.svg?style=flat
[webtorrent-gratipay-url]: https://gratipay.com/feross/
[webtorrent-sauce-image]: https://saucelabs.com/browser-matrix/webtorrent.svg
[sauce-url]: https://saucelabs.com/u/webtorrent-client
[addr-to-ip-port]: https://github.com/feross/addr-to-ip-port
[addr-to-ip-port-ti]: https://img.shields.io/travis/feross/addr-to-ip-port.svg?style=flat
[addr-to-ip-port-tu]: https://travis-ci.org/feross/addr-to-ip-port
[addr-to-ip-port-ni]: https://img.shields.io/npm/v/addr-to-ip-port.svg?style=flat
[addr-to-ip-port-nu]: https://npmjs.org/package/addr-to-ip-port
[bittorrent-dht]: https://github.com/feross/bittorrent-dht
[bittorrent-dht-ti]: https://img.shields.io/travis/feross/bittorrent-dht.svg?style=flat
[bittorrent-dht-tu]: https://travis-ci.org/feross/bittorrent-dht
[bittorrent-dht-ni]: https://img.shields.io/npm/v/bittorrent-dht.svg?style=flat
[bittorrent-dht-nu]: https://npmjs.org/package/bittorrent-dht
[bittorrent-peerid]: https://github.com/fisch0920/bittorrent-peerid
[bittorrent-peerid-ti]: https://img.shields.io/travis/fisch0920/bittorrent-peerid.svg?style=flat
[bittorrent-peerid-tu]: https://travis-ci.org/fisch0920/bittorrent-peerid
[bittorrent-peerid-ni]: https://img.shields.io/npm/v/bittorrent-peerid.svg?style=flat
[bittorrent-peerid-nu]: https://npmjs.org/package/bittorrent-peerid
[bittorrent-protocol]: https://github.com/feross/bittorrent-protocol
[bittorrent-protocol-ti]: https://img.shields.io/travis/feross/bittorrent-protocol.svg?style=flat
[bittorrent-protocol-tu]: https://travis-ci.org/feross/bittorrent-protocol
[bittorrent-protocol-ni]: https://img.shields.io/npm/v/bittorrent-protocol.svg?style=flat
[bittorrent-protocol-nu]: https://npmjs.org/package/bittorrent-protocol
[bittorrent-swarm]: https://github.com/feross/bittorrent-swarm
[bittorrent-swarm-ti]: https://img.shields.io/travis/feross/bittorrent-swarm.svg?style=flat
[bittorrent-swarm-tu]: https://travis-ci.org/feross/bittorrent-swarm
[bittorrent-swarm-ni]: https://img.shields.io/npm/v/bittorrent-swarm.svg?style=flat
[bittorrent-swarm-nu]: https://npmjs.org/package/bittorrent-swarm
[bittorrent-tracker]: https://github.com/feross/bittorrent-tracker
[bittorrent-tracker-ti]: https://img.shields.io/travis/feross/bittorrent-tracker.svg?style=flat
[bittorrent-tracker-tu]: https://travis-ci.org/feross/bittorrent-tracker
[bittorrent-tracker-ni]: https://img.shields.io/npm/v/bittorrent-tracker.svg?style=flat
[bittorrent-tracker-nu]: https://npmjs.org/package/bittorrent-tracker
[buffer]: https://github.com/feross/buffer
[buffer-ti]: https://img.shields.io/travis/feross/buffer.svg?style=flat
[buffer-tu]: https://travis-ci.org/feross/buffer
[buffer-ni]: https://img.shields.io/npm/v/buffer.svg?style=flat
[buffer-nu]: https://npmjs.org/package/buffer
[create-torrent]: https://github.com/feross/create-torrent
[create-torrent-ti]: https://img.shields.io/travis/feross/create-torrent.svg?style=flat
[create-torrent-tu]: https://travis-ci.org/feross/create-torrent
[create-torrent-ni]: https://img.shields.io/npm/v/create-torrent.svg?style=flat
[create-torrent-nu]: https://npmjs.org/package/create-torrent
[ip-set]: https://github.com/fisch0920/ip-set
[ip-set-ti]: https://img.shields.io/travis/fisch0920/ip-set.svg?style=flat
[ip-set-tu]: https://travis-ci.org/fisch0920/ip-set
[ip-set-ni]: https://img.shields.io/npm/v/ip-set.svg?style=flat
[ip-set-nu]: https://npmjs.org/package/ip-set
[load-ip-set]: https://github.com/feross/load-ip-set
[load-ip-set-ti]: https://img.shields.io/travis/feross/load-ip-set.svg?style=flat
[load-ip-set-tu]: https://travis-ci.org/feross/load-ip-set
[load-ip-set-ni]: https://img.shields.io/npm/v/load-ip-set.svg?style=flat
[load-ip-set-nu]: https://npmjs.org/package/load-ip-set
[magnet-uri]: https://github.com/feross/magnet-uri
[magnet-uri-ti]: https://img.shields.io/travis/feross/magnet-uri.svg?style=flat
[magnet-uri-tu]: https://travis-ci.org/feross/magnet-uri
[magnet-uri-ni]: https://img.shields.io/npm/v/magnet-uri.svg?style=flat
[magnet-uri-nu]: https://npmjs.org/package/magnet-uri
[parse-torrent]: https://github.com/feross/parse-torrent
[parse-torrent-ti]: https://img.shields.io/travis/feross/parse-torrent.svg?style=flat
[parse-torrent-tu]: https://travis-ci.org/feross/parse-torrent
[parse-torrent-ni]: https://img.shields.io/npm/v/parse-torrent.svg?style=flat
[parse-torrent-nu]: https://npmjs.org/package/parse-torrent
[parse-torrent-file]: https://github.com/feross/parse-torrent-file
[parse-torrent-file-ti]: https://img.shields.io/travis/feross/parse-torrent-file.svg?style=flat
[parse-torrent-file-tu]: https://travis-ci.org/feross/parse-torrent-file
[parse-torrent-file-ni]: https://img.shields.io/npm/v/parse-torrent-file.svg?style=flat
[parse-torrent-file-nu]: https://npmjs.org/package/parse-torrent-file
[simple-peer]: https://github.com/feross/simple-peer
[simple-peer-ti]: https://img.shields.io/travis/feross/simple-peer.svg?style=flat
[simple-peer-tu]: https://travis-ci.org/feross/simple-peer
[simple-peer-ni]: https://img.shields.io/npm/v/simple-peer.svg?style=flat
[simple-peer-nu]: https://npmjs.org/package/simple-peer
[simple-websocket]: https://github.com/feross/simple-websocket
[simple-websocket-ti]: https://img.shields.io/travis/feross/simple-websocket.svg?style=flat
[simple-websocket-tu]: https://travis-ci.org/feross/simple-websocket
[simple-websocket-ni]: https://img.shields.io/npm/v/simple-websocket.svg?style=flat
[simple-websocket-nu]: https://npmjs.org/package/simple-websocket
[string2compact]: https://github.com/feross/string2compact
[string2compact-ti]: https://img.shields.io/travis/feross/string2compact.svg?style=flat
[string2compact-tu]: https://travis-ci.org/feross/string2compact
[string2compact-ni]: https://img.shields.io/npm/v/string2compact.svg?style=flat
[string2compact-nu]: https://npmjs.org/package/string2compact
[torrent-discovery]: https://github.com/feross/torrent-discovery
[torrent-discovery-ti]: https://img.shields.io/travis/feross/torrent-discovery.svg?style=flat
[torrent-discovery-tu]: https://travis-ci.org/feross/torrent-discovery
[torrent-discovery-ni]: https://img.shields.io/npm/v/torrent-discovery.svg?style=flat
[torrent-discovery-nu]: https://npmjs.org/package/torrent-discovery
[typedarray-to-buffer]: https://github.com/feross/typedarray-to-buffer
[typedarray-to-buffer-ti]: https://img.shields.io/travis/feross/typedarray-to-buffer.svg?style=flat
[typedarray-to-buffer-tu]: https://travis-ci.org/feross/typedarray-to-buffer
[typedarray-to-buffer-ni]: https://img.shields.io/npm/v/typedarray-to-buffer.svg?style=flat
[typedarray-to-buffer-nu]: https://npmjs.org/package/typedarray-to-buffer
[ut_metadata]: https://github.com/feross/ut_metadata
[ut_metadata-ti]: https://img.shields.io/travis/feross/ut_metadata.svg?style=flat
[ut_metadata-tu]: https://travis-ci.org/feross/ut_metadata
[ut_metadata-ni]: https://img.shields.io/npm/v/ut_metadata.svg?style=flat
[ut_metadata-nu]: https://npmjs.org/package/ut_metadata
[ut_pex]: https://github.com/fisch0920/ut_pex
[ut_pex-ti]: https://img.shields.io/travis/fisch0920/ut_pex.svg?style=flat
[ut_pex-tu]: https://travis-ci.org/fisch0920/ut_pex
[ut_pex-ni]: https://img.shields.io/npm/v/ut_pex.svg?style=flat
[ut_pex-nu]: https://npmjs.org/package/ut_pex
[webtorrent-swarm]: https://github.com/feross/webtorrent-swarm
[webtorrent-swarm-ti]: https://img.shields.io/travis/feross/webtorrent-swarm.svg?style=flat
[webtorrent-swarm-tu]: https://travis-ci.org/feross/webtorrent-swarm
[webtorrent-swarm-ni]: https://img.shields.io/npm/v/webtorrent-swarm.svg?style=flat
[webtorrent-swarm-nu]: https://npmjs.org/package/webtorrent-swarm
[webtorrent-tracker]: https://github.com/feross/webtorrent-tracker
[webtorrent-tracker-ti]: https://img.shields.io/travis/feross/webtorrent-tracker.svg?style=flat
[webtorrent-tracker-tu]: https://travis-ci.org/feross/webtorrent-tracker
[webtorrent-tracker-ni]: https://img.shields.io/npm/v/webtorrent-tracker.svg?style=flat
[webtorrent-tracker-nu]: https://npmjs.org/package/webtorrent-tracker
#### Todo
- compress-sdp (compress sdp messages to lighten load on webtorrent trackers & dht)
- protocol extension: protocol encryption
- protocol extension: µTP
- protocol extension: UPnP and NAT-PMP port forwarding
- protocol extension: webseed support
- webtorrent-dht
### Contribute
WebTorrent is an **[OPEN Open Source Project](https://github.com/feross/webtorrent/blob/master/CONTRIBUTING.md)**. Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit.
WebTorrent is only possible due to the excellent work of the following contributors:
<table><tbody>
<tr><th align="left">Feross Aboukhadijeh</th><td><a href="https://github.com/feross">GitHub/feross</a></td><td><a href="http://twitter.com/feross">Twitter/@feross</a></td></tr>
<tr><th align="left">Daniel Posch</th><td><a href="https://github.com/dcposch">GitHub/dcposch</a></td><td><a href="http://twitter.com/dcposch">Twitter/@dcposch</a></td></tr>
<tr><th align="left">John Hiesey</th><td><a href="https://github.com/jhiesey">GitHub/jhiesey</a></td><td><a href="http://twitter.com/jhiesey">Twitter/@jhiesey</a></td></tr>
<tr><th align="left">Travis Fischer</th><td><a href="https://github.com/fisch0920">GitHub/fisch0920</a></td><td><a href="http://twitter.com/fisch0920">Twitter/@fisch0920</a></td></tr>
<tr><th align="left">Astro</th><td><a href="https://github.com/astro">GitHub/astro</a></td><td><a href="http://twitter.com/astro1138">Twitter/@astro1138</a></td></tr>
<tr><th align="left">Iván Todorovich</th><td><a href="https://github.com/ivantodorovich">GitHub/ivantodorovich</a></td><td><a href="http://twitter.com/ivantodorovich">Twitter/@ivantodorovich</a></td></tr>
<tr><th align="left">Mathias Buus</th><td><a href="https://github.com/mafintosh">GitHub/mafintosh</a></td><td><a href="http://twitter.com/mafintosh">Twitter/@mafintosh</a></td></tr>
<tr><th align="left">Bob Ren</th><td><a href="https://github.com/bobrenjc93">GitHub/bobrenjc93</a></td><td><a href="http://twitter.com/bobrenjc93">Twitter/@bobrenjc93</a></td></tr>
</tbody></table>
#### Clone the code
```bash
git clone https://github.com/feross/webtorrent.git
cd webtorrent
npm install
./bin/cmd.js --help
```
#### Enable debug logs
Enable debug output by setting the `DEBUG` environment variable to the name of the module
you want to debug (e.g. `bittorrent-tracker`, or `*` to print **all logs**).
```bash
DEBUG=* ./bin/cmd.js
```
This even works for WebTorrent releases installed with `npm install webtorrent -g`:
```bash
DEBUG=* webtorrent
```
#### Clone all dependencies
WebTorrent is a modular BitTorrent client, so functionality is split up into many
npm modules. You can `git clone` all the relevant dependencies with one command. This
makes it easier to send PRs:
```bash
./bin/clone.sh
```
### Talks about WebTorrent
- Sep 2014 (NodeConf EU) – WebTorrent & WebRTC: Mad Science (first working demo of WebTorrent)
- May 2014 (JS.LA) – [How I Built a BitTorrent Client in the Browser](https://vimeo.com/97324247) (progress update; node client working)
- Oct 2013 (RealtimeConf) – [WebRTC Black Magic (RealtimeConf)](https://vimeo.com/77265280) (where I first shared the idea of WebTorrent)
### Known issues
#### Downloads don't start on Chromebook
Chromebooks are set to refuse all incoming connections by default. To change this, run:
```bash
sudo iptables -P INPUT ACCEPT
```
### License
MIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org).
![Magic](img/logo.png)
|