{"id":13482045,"url":"https://github.com/webtorrent/torrent-discovery","last_synced_at":"2025-04-08T02:42:12.192Z","repository":{"id":19778447,"uuid":"23037077","full_name":"webtorrent/torrent-discovery","owner":"webtorrent","description":"Discover BitTorrent and WebTorrent peers","archived":false,"fork":false,"pushed_at":"2024-07-28T11:14:23.000Z","size":229,"stargazers_count":216,"open_issues_count":5,"forks_count":66,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-08-12T21:27:08.812Z","etag":null,"topics":["bittorrent","bittorrent-dht","bittorrent-tracker","browser","dht","javascript","nodejs","p2p","peer","torrent","tracker","webtorrent"],"latest_commit_sha":null,"homepage":"https://webtorrent.io","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webtorrent.png","metadata":{"funding":{"github":["webtorrent","feross"]},"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-08-17T09:15:38.000Z","updated_at":"2024-08-12T21:27:16.734Z","dependencies_parsed_at":"2023-09-24T02:16:31.111Z","dependency_job_id":"1bc11333-6f54-452d-8e85-49310df7cfd3","html_url":"https://github.com/webtorrent/torrent-discovery","commit_stats":{"total_commits":279,"total_committers":22,"mean_commits":"12.681818181818182","dds":"0.40501792114695345","last_synced_commit":"9316c323b88d5f19efd3c1025893c9959c51f7d7"},"previous_names":["feross/torrent-discovery"],"tags_count":115,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webtorrent%2Ftorrent-discovery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webtorrent%2Ftorrent-discovery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webtorrent%2Ftorrent-discovery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webtorrent%2Ftorrent-discovery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webtorrent","download_url":"https://codeload.github.com/webtorrent/torrent-discovery/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266476,"owners_count":20910831,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bittorrent","bittorrent-dht","bittorrent-tracker","browser","dht","javascript","nodejs","p2p","peer","torrent","tracker","webtorrent"],"created_at":"2024-07-31T17:00:58.475Z","updated_at":"2025-04-08T02:42:12.174Z","avatar_url":"https://github.com/webtorrent.png","language":"JavaScript","funding_links":["https://github.com/sponsors/webtorrent","https://github.com/sponsors/feross"],"categories":["Modules","JavaScript"],"sub_categories":[],"readme":"# torrent-discovery [![ci][ci-image]][ci-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]\n\n[ci-image]: https://github.com/webtorrent/torrent-discovery/actions/workflows/ci.yml/badge.svg\n[ci-url]: https://github.com/webtorrent/torrent-discovery/actions/workflows/ci.yml\n[npm-image]: https://img.shields.io/npm/v/torrent-discovery.svg\n[npm-url]: https://npmjs.org/package/torrent-discovery\n[downloads-image]: https://img.shields.io/npm/dm/torrent-discovery.svg\n[downloads-url]: https://npmjs.org/package/torrent-discovery\n[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg\n[standard-url]: https://standardjs.com\n\n### Discover BitTorrent and WebTorrent peers\n\nThis module bundles [bittorrent-tracker](https://www.npmjs.com/package/bittorrent-tracker), [bittorrent-dht](https://www.npmjs.com/package/bittorrent-dht), and [bittorrent-lsd](https://www.npmjs.com/package/bittorrent-lsd) clients and exposes a single API for discovering BitTorrent peers.\n\n## features\n\n- simple API\n- find peers from trackers, DHT, and LSD\n- automatically announces, so other peers can discover us\n- can start finding peers with just an info hash, before full metadata is available\n\nThis module also **works in the browser** with [browserify](http://browserify.org). In\nthat context, it discovers [WebTorrent](http://webtorrent.io) (WebRTC) peers.\n\n## install\n\n```\nnpm install torrent-discovery\n```\n\n## api\n\n### `discovery = new Discovery(opts)`\n\nCreate a new peer discovery instance. Required options are:\n\n```js\n{\n  infoHash: '', // as hex string or Buffer\n  peerId: '',   // as hex string or Buffer\n  port: 0       // torrent client port (only required in node)\n}\n```\n\nOptional options are:\n\n```js\n{\n  announce: [],  // force list of announce urls to use (from magnet uri)\n  dht: true,     // use dht? optionally, this can be an `opts` object, or a DHT instance to use (can be reused for multiple torrents)\n  dhtPort: 0,    // custom listen port for the DHT instance (not used if DHT instance is given via `opts.dht`)\n  userAgent: '', // User-Agent header for http requests\n  tracker: true, // use trackers? optionally, this can be an `opts` object\n  lsd: true      // use lsd?\n}\n```\n\nSee the documentation for [bittorrent-tracker](https://www.npmjs.com/package/bittorrent-tracker), [bittorrent-dht](https://www.npmjs.com/package/bittorrent-dht), and [bittorrant-lsd](https://www.npmjs.com/package/bittorrent-lsd) for information on what options are available via the `opts` object.\n\n**This module automatically handles announcing on intervals, for maximum peer discovery.**\n\n### `discovery.updatePort(port)`\n\nWhen the port that the torrent client is listening on changes, call this method to\nreannounce to the tracker and DHT with the new port.\n\n### `discovery.complete([opts])`\n\nAnnounce that download has completed (and the client is now a seeder). This is only\nused by trackers, for statistical purposes. If trackers are not in use, then\nthis method is a no-op.\n\nOptional `opts` object with the following options:\n\n```\n{number=} opts.uploaded\n{number=} opts.downloaded\n{number=} opts.numwant\n{number=} opts.left (if not set, calculated automatically)\n```\n\n### `discovery.destroy()`\n\nDestroy and cleanup the tracker, DHT, and LSD instances.\n\n### events\n\n### `discovery.on('peer', (peer, source) =\u003e {})`\n\nEmitted whenever a new peer is discovered. Source is either `'tracker'`, `'dht'`, or `'lsd'` based on peer source.\n\n**In node**, `peer` is a string in the form `ip:port`, e.g. `12.34.56.78:4000`.\n\n**In the browser**, `peer` is an instance of\n[`simple-peer`](https://www.npmjs.com/package/simple-peer), a small wrapper around a WebRTC\npeer connection.\n\n### `discovery.on('dhtAnnounce', () =\u003e {})`\n\nEmitted whenever an `announce` message has been sent to the DHT.\n\n### `discovery.on('warning', err =\u003e {})`\n\nEmitted when there is a **non-fatal** tracker, DHT, or LSD error. For example, an\ninaccessible tracker server would be considered a warning. Useful for logging.\n\n### `discovery.on('error', err =\u003e {})`\n\nEmitted when there is a fatal tracker, DHT, or LSD error. This is unrecoverable\nand the `discovery` object will be destroyed if this event is emitted.\n\n## license\n\nMIT. Copyright (c) [Feross Aboukhadijeh](https://feross.org) and [WebTorrent, LLC](https://webtorrent.io).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebtorrent%2Ftorrent-discovery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebtorrent%2Ftorrent-discovery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebtorrent%2Ftorrent-discovery/lists"}