Magnet URI scheme

From Pulsed Media Wiki

Magnet URI Scheme

The Magnet URI scheme, commonly referred to as a magnet link, is a type of hyperlink used to identify and download files based on their content rather than their location. It is widely used in peer-to-peer (P2P) networks, especially in the BitTorrent protocol, to enable decentralized file sharing without needing a centralized tracker or a separate .torrent file.

Magnet links are content-addressable, meaning they rely on a unique hash of the file's content to locate it among peers in the network.

Format

A typical magnet URI looks like this:

<syntaxhighlight lang="text"> magnet:?xt=urn:btih:<hash>&dn=<filename>&tr=<tracker_url> </syntaxhighlight>

Where:

  • xt – Exact topic (the unique hash of the file, usually in SHA-1 for BitTorrent)
  • dn – Display name (optional, shows the file name)
  • tr – Tracker URL (optional, assists in peer discovery)
  • xl – Exact length (file size in bytes, optional)
  • xs – Exact source (URL to the file, optional)

Example

<syntaxhighlight lang="text"> magnet:?xt=urn:btih:5a3b3e5e38b1b9c54bb3e1f3f5b5e5d9c7123e5f&dn=Ubuntu+ISO&tr=udp://tracker.openbittorrent.com:80 </syntaxhighlight>

This magnet link represents a torrent with a specific hash, suggests a display name "Ubuntu ISO," and provides a tracker to assist in finding peers.

How Magnet Links Work

1. A user clicks a magnet link in a torrent index site or application. 2. The BitTorrent client reads the content hash (btih) from the link. 3. The client searches for peers using:

  * Distributed Hash Table (DHT)
  * Peer Exchange (PEX)
  * Optional trackers included in the link

4. Once peers are found, the client begins downloading the file directly from them.

Advantages

  • No need for .torrent files – Reduces server load and dependency on external hosting
  • Decentralized – Works even without a central tracker
  • Permanent and portable – The hash uniquely identifies the content, not the location
  • Easy to share – Can be distributed via websites, email, QR codes, etc.

Disadvantages

  • Slightly slower startup – Initial peer discovery can take longer compared to using a .torrent file with tracker info
  • Less metadata – Unless included in the link, magnet links don't contain detailed file lists or folder structures

Use in BitTorrent

Magnet links are now widely supported by all major BitTorrent clients, including:

They are commonly used on public and private torrent index websites in place of traditional .torrent file downloads.

See Also