Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

use-rest-api

БесплатноБез исполняемых скриптовНе проверен

Call the tracker REST API: authentication, stats, metrics, torrents, auth keys and whitelist. Use when querying or testing the API, for example with curl.

torrustот torrust★ 539 звёзд на GitHub

Об этом скилле

Use REST API

Prerequisites

A running tracker with the REST API enabled. The default development config starts the API on port 1212:

cargo run

Skill Links

This skill depends on these artifacts. If any of them change, review this skill.

  • share/default/config/tracker.development.sqlite3.toml
  • packages/axum-rest-api-server/src/v1/middlewares/auth.rs
  • packages/axum-rest-api-server/src/routes.rs
  • packages/axum-rest-api-server/src/v1/routes.rs

Use the marker skill-link: use-rest-api in affected artifacts.

Authentication

All API endpoints (except /api/health_check) require an access token.

Header Method (preferred)

curl -H "Authorization: Bearer MyAccessToken" http://localhost:1212/api/v1/stats

Query Parameter Method (accepted, not recommended)

The server still accepts the token as a ?token= query parameter, but a URL, with its query, is written to proxy, browser and server logs. Send the header instead: it keeps the token out of the URL. That is not every log (a proxy or server set to log request headers still records it), and it does not protect the token in transit, which needs HTTPS. Do not write the query form in examples (see the handle-secrets skill).

Neither form keeps a token out of your shell history: a token typed on a command line is saved there, in a header as much as in a URL. For a real token, read it from a file or an environment variable inside the command (for example -H "Authorization: Bearer $(cat token-file)"), as the examples here use a placeholder only.

Configuration

Tokens are defined in the TOML config file under [http_api.access_tokens]:

[http_api.access_tokens]
admin = "MyAccessToken"

Every token in the map has identical permissions — the label (admin) is just a human-readable name.

Endpoints

All endpoints use http://localhost:1212 as base (default dev config).

Health Check

Method Endpoint Auth
GET /api/health_check ❌ No
curl -s http://localhost:1212/api/health_check

Stats

Method Endpoint Auth
GET /api/v1/stats ✅ Yes
GET /api/v1/metrics ✅ Yes
curl -s http://localhost:1212/api/v1/stats -H "Authorization: Bearer MyAccessToken"
curl -s http://localhost:1212/api/v1/metrics -H "Authorization: Bearer MyAccessToken"

Auth Keys

Method Endpoint Auth
POST /api/v1/key/{seconds_valid_or_key} ✅ Yes
DELETE /api/v1/key/{seconds_valid_or_key} ✅ Yes
GET /api/v1/keys/reload ✅ Yes
POST /api/v1/keys ✅ Yes

Whitelist

Method Endpoint Auth
POST /api/v1/whitelist/{info_hash} ✅ Yes
DELETE /api/v1/whitelist/{info_hash} ✅ Yes
GET /api/v1/whitelist/reload ✅ Yes

Torrents

Method Endpoint Auth
GET /api/v1/torrent/{info_hash} ✅ Yes
GET /api/v1/torrents ✅ Yes

Making Announce Requests with the Tracker Client

The tracker_client binary can make BitTorrent announce requests to verify the tracker is working.

UDP Announce

tracker_client writes JSON to stdout and refuses to run when stdout is a terminal (exit 2, a tty_refusal record on stderr), so the commands below pipe the output to jq. Pipe or redirect it the same way in your own commands.

cargo run -p torrust-tracker-client --bin tracker_client -- udp announce udp://localhost:6969/announce 0123456789abcdef0123456789abcdef01234567 | jq .

HTTP Announce

cargo run -p torrust-tracker-client --bin tracker_client -- http announce http://localhost:7070/announce 0123456789abcdef0123456789abcdef01234567 | jq .

Scrape

cargo run -p torrust-tracker-client --bin tracker_client -- udp scrape udp://localhost:6969/announce 0123456789abcdef0123456789abcdef01234567 | jq .

Output defaults to JSON. Use --format text for human-readable output.

Verification Workflow

After making an announce request, verify the API reflects the activity:

  1. Check stats changed:

    curl -s http://localhost:1212/api/v1/stats -H "Authorization: Bearer MyAccessToken"
    

    Expect torrents and seeders to increase.

  2. Check metrics changed:

    curl -s http://localhost:1212/api/v1/metrics -H "Authorization: Bearer MyAccessToken"
    

    Expect protocol-specific counters to increase.

  3. Check tracker console logs show the request was received:

    active_peers_total=1 active_torrents_total=1
    
Полный SKILL.md на GitHub

Установить use-rest-api в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл use-rest-api?

Call the tracker REST API: authentication, stats, metrics, torrents, auth keys and whitelist. Use when querying or testing the API, for example with curl.

Как установить скилл use-rest-api?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл use-rest-api запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить use-rest-api с