TorrentSearchNet 1.0.0

dotnet add package TorrentSearchNet --version 1.0.0
                    
NuGet\Install-Package TorrentSearchNet -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TorrentSearchNet" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TorrentSearchNet" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="TorrentSearchNet" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TorrentSearchNet --version 1.0.0
                    
#r "nuget: TorrentSearchNet, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TorrentSearchNet@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TorrentSearchNet&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=TorrentSearchNet&version=1.0.0
                    
Install as a Cake Tool

TorrentSearchNet

A small library that helps with finding torrents for legal file sharing.
Supports searching and file inspection through multiple torrent APIs.

NuGet: TorrentSearchNet on nuget.org


๐Ÿ“ฆ Installation

Install via NuGet:

dotnet add package TorrentSearchNet

๐Ÿš€ Quick Start

Search for torrents:

using TorrentSearchNet;

SearchResult result = await TorrentFinder.SearchAsync("ubuntu", Category.AppOther);

foreach (TorrentFileInfo file in result.Files)
{
    Console.WriteLine(file); // see output example below for what this outputs
    Console.WriteLine(file.GetMagnetLink()); // see output example below
}

๐Ÿ“ค Output Example

Ubuntu 22.04 ISO | AppOther | 3,155 MB | Seeders: 195 | Leechers: 12 | Added: 2024-06-01 | By: linuxfan
magnet:?xt=urn:btih:ABC123...&dn=Ubuntu+22.04+ISO&tr=...

Get the files contained in a torrent:

ContainedFilesResult contents = await TorrentFinder.GetContainedFilesAsync("36418511");

foreach (ContainedFilesInfo file in contents.Files)
{
    Console.WriteLine($"{file.Name} - {file.Size} bytes");
}

You can easily get a magnet link from a TorrentFileInfo:

TorrentFileInfo file = ...;
MagnetLink magnet = file.GetMagnetLink();
Console.WriteLine(magnet); // prints the full magnet URI

โš™๏ธ Configuration

๐Ÿ”Œ Adding Custom Providers

You can add your own implementations of ITorrentApi using:

TorrentFinder.AddTorrentApi(new MyCustomApi());

By default, the library uses a built-in provider called PhpApi, which targets the PirateBay-like API structure. Adding your own ITorrentApi allows you to extend or replace the default behavior, e.g., to support private trackers or alternative backends.


๐ŸŒ Setting the PhpApi Base URL

The default base URL for the PhpApi is:

PhpApiSettings.Url = "https://apibay.org";

You can override it to point to any other compatible API:

PhpApiSettings.Url = "https://thepiratebay.cloud";

By default, generated magnet links include public trackers. You can view and modify them using:

MagnetLinkSettings.PublicTrackers.Add("udp://your.custom.tracker:1337/announce");
MagnetLinkSettings.PublicTrackers.RemoveAt(0); // if you want to remove defaults

๐Ÿ“„ Models

TorrentFileInfo

  • .Name โ€” Display name of the torrent
  • .InfoHash โ€” The info hash used in the magnet link
  • .Size โ€” Size in bytes
  • .Seeders, .Leechers โ€” Stats
  • .Category โ€” Enum-based category
  • .GetMagnetLink() โ€” Returns a MagnetLink instance

ContainedFilesInfo

  • .Name โ€” File name inside the torrent
  • .Size โ€” File size in bytes

๐Ÿงช Testing

You can run your own unit tests using MSTest or another compatible test framework. The library is designed to be testable, with mockable APIs via ITorrentApi.


Torrenting and peer-to-peer file sharing are not inherently illegal. This library is intended solely for legal use cases, such as downloading or distributing open-source software, public domain content, or other freely licensed material.

Illegal activity, such as sharing or downloading copyrighted material without proper authorization, is illegal and may result in legal consequences depending on your jurisdiction.

The developer of this library does not condone, support, or take responsibility for the misuse of this library in any unlawful manner. Use responsibly.


๐Ÿ“š License

MIT License

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 164 4/20/2025