Repository navigation
Writing a Plugin
Use this page to make trackarr read a tracker it does not support yet, or to fix a plugin that stopped working. You do not need to know the plugin format first. Every YAML key is in the Plugin reference.
Every plugin does the same thing: it asks the tracker for a page or an API answer, picks the numbers out of it, and tells trackarr which number is which. Trackers differ in what that answer looks like, and the shape of the answer decides how the plugin picks the numbers out.
| Kind | What the tracker answers | How the plugin reads it | Official plugins of this kind |
|---|---|---|---|
| UNIT3D | A standard JSON API, the same on every UNIT3D tracker | the unit3d base, already written |
aither, blutopia, capybarabr, fearnopeer, seedpool and 40 more |
| Its own JSON API | JSON, but in a format only this tracker uses |
path, by field name |
myanonamouse |
| HTML page | The same web page you see in the browser |
regex, by searching the page text |
bj-share, asc
|
Reading JSON is easy and rarely breaks. Reading HTML works on any site but breaks whenever the site changes its layout. So always check the kinds in the order of the table: use HTML only when the tracker has no API.
flowchart TD
A[New tracker] --> B{"Footer or About says UNIT3D?<br/>Settings have an API key?"}
B -- yes --> C{"/api/user?api_token=KEY<br/>returns your stats as JSON?"}
C -- yes --> U[UNIT3D: extends: unit3d]
C -- no --> D
B -- no --> D{"Tracker documents an API,<br/>or DevTools shows JSON with your stats?"}
D -- yes --> J[Own JSON API: start from myanonamouse.yaml]
D -- no --> H{"Page source has your stats<br/>inside a block of JSON?"}
H -- yes --> E[HTML with embedded JSON: start from asc.yaml]
H -- no --> R[Plain HTML: start from bj-share.yaml]
You need:
- an account on the tracker, logged in in your browser;
- the browser's developer tools (DevTools): F12 in Chrome, Firefox and Edge;
- trackarr running, to create the plugin and press Test (see Managing plugins).
A plugin logs in with one of two kinds of credential. Find out which one the tracker offers:
- API key (or API token): a long random string the tracker gives you in your account settings. It is the best option, because it does not expire when you log out.
-
Cookie: what your browser sends to prove you are logged in. To copy it, open DevTools, go to the Network tab, reload the page, click the first request (the page itself), and under Request Headers copy the whole value of
Cookie. A cookie stops working when you log out or the session expires, and then the plugin reports an authentication failure until you paste a new one.
Caution
An API key or a cookie gives full access to your tracker account. Never paste one into an issue, a pull request, a chat or a screenshot. trackarr keeps it only in your own instance.
UNIT3D is open-source tracker software that many trackers run, each with its own look. Because the software is the same, they all have the same API, so one plugin works for all of them after changing its name and address.
- The page footer, or the About page, mentions UNIT3D.
- Addresses look like
/torrents,/users/<your name>,/forums,/requests. - Your account settings have an API key page, at
users/<your name>/apikeys. -
Prowlarr lists the engine of each tracker it knows on the last line of its definition, for example
# json UNIT3D 9.2.0. A line that says(custom)orbased on UNIT3Dmeans a modified UNIT3D, which may answer differently.
To be sure, copy your API key and open this address in the browser, with your tracker and key:
https://tracker.example/api/user?api_token=YOUR_KEY
If the browser shows JSON with your name and stats, the tracker is UNIT3D. It looks like this (shortened, values made up):
{
"username": "alice",
"uploaded": "1.23 TiB",
"downloaded": "512.00 GiB",
"ratio": "2.46",
"buffer": "1.01 TiB",
"seeding": 42,
"leeching": 1,
"seedbonus": "12345.00",
"hit_and_runs": 0
}The address only exists from UNIT3D 8.3.5 on. An older tracker answers with an error page, and no UNIT3D plugin works with it.
The UNIT3D plugin is already written, as the unit3d base. A plugin for one more UNIT3D tracker only names it and points at it (trackarr 0.5.3 and later):
pluginId: my-tracker # lowercase letters, digits and hyphens
displayName: My Tracker # the name shown in the UI
version: 1.0.0
schemaVersion: 2 # 2 is the format that has 'extends'
extends: unit3d
baseUrls:
- https://tracker.example/ # the tracker's address, ending in /Every other key comes from the base, which matches the UNIT3D API:
- the
userstep requestsapi/user?api_token={{apiKey}}, where{{apiKey}}is replaced by the key the user types in the integration form; - each
extractentry takes one field of the JSON by its name (path: "uploaded"); -
transform: byteSizeturns text such as1.23 TiBinto a number of bytes, which is what trackarr stores; -
validatechecks thatusernameis not empty, so an answer that is not really your account is not saved as zeros.
If the tracker is a modified UNIT3D and one field is missing or different, Test fails on that field. Write that key in your plugin: a key the plugin sets replaces the base's whole. For example, to drop the buffer tile, copy the dashboard from the base without it. The Plugin reference explains the rules of bases.
Some trackers have an API of their own, with field names and a structure no other tracker uses. The plugin still reads the JSON by field name, but you have to discover the names yourself.
- The tracker's wiki, FAQ or forum mentions an API, JSON, or a script for seedboxes.
- Or open DevTools, go to the Network tab, choose the Fetch/XHR filter and reload your profile or the home page. Click each request and look at its Response tab. If one of them answers JSON containing your upload, download or ratio, that is the API the plugin will call.
myanonamouse.yaml calls jsonLoad.php?snatch_summary. The credential is a cookie named mam_id, which MyAnonamouse creates in Preferences > Security for a session locked to an IP address, so the plugin sends it with http.cookies instead of asking for the whole Cookie header:
http:
cookies:
mam_id: "{{mamId}}"The answer has some values at the top and others nested inside objects:
{
"username": "alice",
"uploaded": "1.23 TiB",
"ratio": "2.46",
"snatch_summary": {
"sSat": { "count": 120 },
"leeching": { "count": 1 }
}
}path follows the nesting with dots: path: "snatch_summary.sSat.count" reads 120. Field names are case-insensitive. Lists ([ ... ]) cannot be read by position; if the number you need is only inside a list, this kind does not fit and the tracker has to be read some other way.
MyAnonamouse splits seeding torrents into several counters, and trackarr wants one number, so the mapping line adds them: seedingTorrents: "steps.user.seeding_satisfied + steps.user.seeding_unsatisfied + ...".
The plugin also has a validate rule with onFail: authFailed on username. An answer with an empty username then counts as a login failure, and trackarr tells the user to replace the credential instead of showing a generic error.
When there is no API, the plugin downloads the same page you see in the browser and searches its text with a regular expression (regex): a pattern that describes the text around the number, with a marked spot for the number itself.
This is what is left when the first two kinds do not apply. Older tracker software, such as the Gazelle family that BJ-Share is based on, has addresses like user.php?id=123 and torrents.php.
Before writing regexes, open your profile, press Ctrl+U (view source) and search for "stats", "user" or your upload amount. If the numbers are inside a large block of JSON written into the page, read HTML with embedded JSON: the regexes are much simpler.
The text you see on screen is not always the text in the source. Always work from the source:
- Open the page that shows the stat, for example your profile.
- Press Ctrl+U to view the source, then Ctrl+F to search for the label next to the number (
Enviado,Uploaded,Ratio) or for the number itself. - Look at the text right before and after the number. That is what the regex has to describe.
On BJ-Share the profile shows the upload in a tooltip. The source, simplified, is:
<li class="tooltip" title="1,23 TB">Enviado: 1,23 TB</li>and the plugin's regex for it is:
uploadedBytes:
regex: "<li\\s+class=\"tooltip\"\\s+title=\"(?<value>[^\"]+)\">\\s*Enviado:"
transform: byteSizeWithout the YAML escaping (explained below), the pattern is <li\s+class="tooltip"\s+title="(?<value>[^"]+)">\s*Enviado:. Read from left to right, it says: find an <li tag with class tooltip, take everything inside its title="..." as the value, and only accept it if the text right after the tag starts with Enviado:. The label Enviado: is what tells it apart from the Baixado: (downloaded) item, which has the same shape.
| Piece | Means | Example from BJ-Share |
|---|---|---|
(?<value>...) |
The part to capture. Everything else only locates it. | title="(?<value>[^"]+)" |
[^"]+ |
One or more characters that are not ": everything up to the end of an attribute |
Inside title="..."
|
[^>]* |
Any characters up to the end of the tag: skips attributes you do not care about | <span[^>]*> |
[\d\.,]+ |
A number with digits, dots and commas |
(?<value>[\d\.,]+) for the bonus points |
\s*, \s+
|
Zero or more, or one or more, spaces or line breaks | Ratio:\s*<span |
.*? |
Anything, as little as possible, line breaks included: jumps from a landmark to the value | id="stats_bjpontos"[^>]*>.*?<span |
trackarr runs every regex ignoring case, and . also matches line breaks, so you do not need flags. If a pattern matches more than once, the first match is used.
A good regex starts from a landmark that does not change, such as a label (Enviado:), an id (stats_bjpontos) or a distinctive class, and captures as little as possible around it. Avoid depending on the order of elements or on the exact number of spaces.
Some trackers do not show how many torrents you are seeding, only a list. BJ-Share's seeding step opens torrents.php?type=seeding&username={{username}} and counts the rows of the table:
seedingTorrents:
regex: "<tr[^>]*class=\"[^\"]*torrent[^\"]*torrent_row[^\"]*\"[^>]*>"
countMatches: trueWith countMatches: true the value is the number of matches, not a captured text. The pattern must match each row exactly once, and nothing else on the page. If the list is split into pages, only the first page is counted.
When a cookie expires, most HTML trackers answer with the login page and status 200, which is not an error by itself. authFailure.htmlPatterns lists text that only the login page has; when any step's page contains one (ignoring case), the sync ends as an authentication failure:
authFailure:
htmlPatterns:
- "name=\"password\""
- "type=\"password\""Choose text that never appears on a page of a logged-in user. A common word such as Login can also be in the menu or footer of every page, which would make every sync fail.
Modern sites often write their data into the page as JSON for their JavaScript. asc.yaml reads the dashboard page of Amigos Share Club, whose source contains something like:
"stats":{"ratio":2.46,"uploaded":1352497225728,"downloaded":549755813888,"seeding":42, ...}
The response is HTML, so path cannot be used, but the regexes only need the field name:
uploadedBytes:
regex: "\"stats\":\\{.*?\"uploaded\":(?<value>\\d+)"That is: find "stats":{, skip ahead to "uploaded":, capture the digits. The bytes are already a plain number, so no byteSize is needed. The logged-out page is recognised by "auth":{"user":null, the same data with no user.
- Build and test the pattern at regex101.com with the .NET (C#) flavour and the
iandsflags, pasting a piece of the page source as the test string. - Put it in YAML inside double quotes, and change two things: every
\becomes\\, and every"becomes\". Sotitle="(?<value>[^"]+)"becomes"title=\"(?<value>[^\"]+)\"".
The editor in trackarr marks a YAML string that is not closed properly before you can save.
- Layout changes. When the tracker changes its pages, regexes stop matching and the sync ends with an unknown error. Repeat Find the number in the page source and adjust the regex.
-
Language. BJ-Share's regexes look for the Portuguese labels
Enviado:andBaixado:. If the tracker lets you change the interface language, the labels change with it. Prefer anidor class as the landmark when there is one. -
Number formats.
integeranddecimalaccept both.and,as separators, so1.234,56is fine.byteSizeneeds the number and the unit in the same captured text (1,23 TB). If the page puts them in separate tags, look for another spot that has both, such as atitleattribute.
Whatever the kind, a plugin has the same parts. The extract names are yours to choose; mapping connects them to the stats trackarr knows:
mapping:
ratio: "steps.profile.ratio" # required
uploadedBytes: "steps.profile.uploadedBytes" # required, in bytes
downloadedBytes: "steps.profile.downloadedBytes" # required, in bytes
requiredRatio: "fields.required_ratio" # required, always this line
seedingTorrents: "steps.seeding.seedingTorrents" # required
leechingTorrents: "steps.leeching.leechingTorrents" # required
activeTorrents: "steps.seeding.seedingTorrents + steps.leeching.leechingTorrents" # required
seedBonus: "steps.profile.seedBonus" # optionalIf the tracker does not show a required count at all, map it to 0 (a literal number is allowed) instead of leaving it out. dashboard.metrics then picks which stats appear as tiles on the card; the ratio is always shown.
Then, in trackarr:
- On Manage Plugins, click New Plugin, paste the YAML, set your
pluginIdand click Create Plugin. - On the dashboard, create an integration with that plugin and your credential.
- Back in the plugin editor, click Test and pick that integration. Change the YAML and test again until the outcome is
successand the numbers match what the tracker shows.
| Test result | Usual cause | What to do |
|---|---|---|
authFailed |
The API key or cookie is wrong or expired, or an authFailure pattern also matches a logged-in page |
Copy the credential again; check that no htmlPatterns text appears on the normal page |
unknownError on a field |
The regex did not match, or the JSON has no such field | Compare with the page source or the JSON again; for JSON, check the spelling and nesting of path
|
unknownError with an HTTP status |
The step's url is wrong, or the tracker refused the request |
Open the same address in the browser while logged in |
| A value that does not parse | The captured text is not what the transform expects |
Look at what was captured: a regex that grabs too much, or byteSize without a unit |
A plugin you created lives only in your trackarr. To make it official, so that every install receives it and its fixes, send it as a pull request (PR) to trackarr-plugins. A fix to an official plugin goes the same way. trackarr cannot open the PR for you. The full rules are in CONTRIBUTING.md.
- A GitHub account.
-
Git, and optionally the GitHub CLI (
gh), which saves a few clicks. -
Node 22+ with pnpm, to generate
index.json. - The .NET 10 SDK, to run the same validator the app and CI use.
The pull request needs a regenerated index.json, and CI rejects it otherwise, so editing the file only on the GitHub website is not enough. If you cannot install these tools, open an issue instead, with the tracker's name, its kind (UNIT3D, own API or HTML) and the YAML. Remove every cookie, key and username first.
A fork is your own copy of the repository on GitHub, where you can push. With the GitHub CLI:
gh repo fork leandrobattochio/trackarr-plugins --clone
git clone https://github.com/leandrobattochio/trackarr.git # only for the validator
cd trackarr-pluginsWithout it, click Fork on the repository page, then git clone the address of your fork. Keep trackarr and trackarr-plugins side by side in the same folder.
Then create a branch for your change:
git switch -c add-my-tracker # or fix-bj-share-ratio-
In trackarr, open the plugin in the editor and copy all of its YAML.
-
Save it as
plugins/<pluginId>.yaml, for exampleplugins/my-tracker.yaml. The file name must equal thepluginId, and the extension must be.yaml, not.yml. -
Set the version fields:
-
New plugin:
version: 1.0.0,schemaVersion: 1(or2withextends), and onechangelogentry for1.0.0with today's date. -
Fix to an official plugin: raise
version(a regex fix is a patch,1.0.0to1.0.1; a new metric is a minor,1.1.0; a new required field is a major,2.0.0) and add achangelogentry for it at the top of the list.
changelog: - version: 1.0.1 date: "2026-11-08" notes: Reads the ratio again after the tracker changed its profile page. - version: 1.0.0 date: "2026-11-07" notes: First release in the trackarr-plugins repository.
-
New plugin:
-
Check every credential field: it needs
sensitive: trueand adescriptionthat tells a new user where to find the value, as in the MyAnonamouse plugin.
Any change to the file, even a comment, must raise version: trackarr detects updates by the file's hash, so the change reaches every user.
From the trackarr-plugins folder:
dotnet run --project ../trackarr/backend/tools/TrackerStats.PluginValidator -- --bases bases plugins/*.yaml
pnpm install
pnpm build-indexThe validator prints OK or INVALID with the reason for each file. pnpm build-index rewrites index.json and fails when two files have the same id, a file name differs from its id, or a changed plugin did not raise its version. Fix what they report and run them again until both pass.
Commit the plugin and the new index.json in the same commit:
git add plugins/my-tracker.yaml index.json
git commit -m "feat: add the My Tracker plugin"
git push -u origin add-my-trackerRun gh pr create, or open your fork on GitHub and click Compare & pull request. The target must be leandrobattochio/trackarr-plugins, branch main. In the description, write:
- the tracker and its kind (UNIT3D, own JSON API or HTML);
- which account class you tested with, since some trackers show different pages to different classes;
- the result of Test in trackarr: the outcome and the stats it read.
Do not paste the raw response of a step, a screenshot of DevTools or the integration settings: they often contain your cookie, key or username.
A few minutes after you open the PR, the CI / validate check runs the validator and the index check on GitHub. A green check means the format is right. A red cross has a Details link with the error, usually one of these:
| CI error | Fix |
|---|---|
INVALID from the validator |
The YAML breaks a rule; the message names the key. Fix it, then run step 3 again |
index.json is out of date |
Run pnpm build-index and commit index.json again |
changed since ... but version ... is not greater than ... |
Raise version and add the changelog entry |
Each new push to the same branch updates the PR and runs CI again. The reviewer may ask for changes in comments; answer them with more commits on the same branch.
On its next restart, every trackarr downloads the plugin (see Plugin updates). Your own install keeps using your copy until you remove it:
- Fix to an official plugin: your install shows a newer official version. Click Use official on the review screen to drop your override and receive future updates automatically.
- New plugin: your custom plugin hides the official one with the same id, and trackarr shows a notice. The Promote a custom plugin section explains how to switch.