---
id: "magnet_link"
kind: "datatype"
status: "stable"
is_pii: false
categories: ["internet", "identifiers"]
langs: ["common"]
quality: 90
url: "http://registry.apicrafter.io/datatype/magnet_link"
---

# Magnet URI (BitTorrent) (`magnet_link`)

URI of the magnet: scheme that identifies a file or a torrent by a hash of its content instead of by its location, used by BitTorrent and other peer-to-peer clients. The parameter xt (exact topic) holds a URN such as urn:btih:<info hash> for BitTorrent v1 (BEP 9) or urn:btmh:<multihash> for v2 (BEP 52); optional parameters include dn (display name), tr (tracker URL), ws (web seed) and xs (exact source). The regexp requires an xt parameter, in any position.

- Parent datatype: `uri`
- Personal data (PII): no
- Categories: Internet (internet), Universal unique identifiers (identifiers)
- Countries: global
- Languages: Common to most languages (common)
- Classification: identifier

## Detection

Regular expression (Python `re`):

```
^magnet:\?(?:[^\s&#]*&)*xt(?:\.[0-9]+)?=urn:[A-Za-z0-9][A-Za-z0-9-]{0,31}:[^\s&#]+(?:&[^\s#]*)?$
```

## Examples

- `magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969` — Sintel magnet link published by WebTorrent, cut to one tracker
- `magnet:?xt=urn:btih:dd8255ecdc7ca55fb0bbf81323d87062db1f6d1c&dn=Big+Buck+Bunny` — Big Buck Bunny, published by WebTorrent
- `magnet:?dn=Sintel&xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10` — Display name before the exact topic
- `magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10` — Exact topic only
- `magnet:?dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969` (invalid example) — No exact topic (xt)
- `https://webtorrent.io/torrents/sintel.torrent` (invalid example) — URL of a .torrent file

## Metacrafter rules

2 rules: 1 match the field name, 1 match values.

- `magnetlinkfield` (field, `common/internet.yaml`)
- `magnetlinkvalue` (data, `common/internet.yaml`)

## Supported by tools

- `metacrafter`

## Translations

- ru: Magnet-ссылка: URI схемы magnet:, который указывает файл или торрент по хешу содержимого, а не по адресу.

## Sources

- wikipedia: <https://en.wikipedia.org/wiki/Magnet_URI_scheme>
- doc: <https://www.bittorrent.org/beps/bep_0009.html>
- doc: <https://www.bittorrent.org/beps/bep_0052.html>

## Quality

Score 90/100. Missing: mapping (Wikidata, Schema.org, ...).

JSON: <http://registry.apicrafter.io/api/v1/datatypes/magnet_link.json> · Edit: <https://github.com/apicrafter/metacrafter-registry/edit/main/data/datatypes/any/internet/magnet_link.yaml>
