npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

alldebrid

v2.0.4

Published

AllDebrid SDK + CLI in TypeScript

Readme

AllDebrid SDK + CLI

TypeScript SDK and Command Line Interface for the AllDebrid API.

📦 Installation

Global CLI Installation

npm install -g alldebrid
# or
pnpm add -g alldebrid

alldebrid --help

Local SDK Installation

npm install alldebrid
# or  
pnpm add alldebrid

🚀 Quick Start

SDK Usage

import { Alldebrid } from "alldebrid";

const client = new Alldebrid({
  apiKey: process.env.ALLDEBRID_API_KEY!,
  logLevel: "warn", // optional: fatal|error|warn|info|debug|trace
  baseUrl: "https://api.alldebrid.com/v4", // optional
});

// Get user info
const user = await client.user.get();

// List magnets with status filter
const ready = await client.magnet.list("ready");

// Get specific magnet details
const magnet = await client.magnet.get(123456);

// Upload a magnet
const result = await client.magnet.upload(["magnet:?xt=urn:btih:..."]);

// Unlock a premium link
const unlocked = await client.link.debrid("https://example.com/file");

CLI Usage

# Set API key (one of these methods)
export ALLDEBRID_API_KEY="your-api-key"
alldebrid --apikey "your-api-key" user info
# or create config file (see Configuration section)

# User commands
alldebrid user info
alldebrid user hosts
alldebrid user saved-links-list

# Magnet commands  
alldebrid magnet list
alldebrid magnet list --status ready
alldebrid magnet get 123456
alldebrid magnet upload "magnet:?xt=urn:btih:..."
alldebrid magnet delete 123456

# Link commands
alldebrid link info "https://example.com/file"
alldebrid link unlock "https://example.com/file"

# Host commands
alldebrid hosts
alldebrid host-domains
alldebrid host-priorities

# Output formats
alldebrid user info --format json
alldebrid user info --format yaml
alldebrid user info --format text  # default, with colors

📖 Documentation

✨ Features

SDK

  • 🔷 TypeScript first - Full type safety with Zod validation
  • 🔄 Complete API coverage - All AllDebrid endpoints supported
  • 🛡️ Error handling - Structured error types with retry logic
  • 📊 Logging - Configurable logging with Pino
  • 🧪 Well tested - Unit and E2E tests

CLI

  • 🎨 Beautiful output - Colorized text with clean formatting
  • 📄 Multiple formats - JSON, YAML, and human-readable text
  • ⚙️ Flexible config - Environment variables, flags, or config files
  • 🔑 Multiple auth methods - API key via flag, env, or config
  • 📍 Cross-platform - Works on Windows, macOS, and Linux

🏗️ Architecture

SDK Structure

src/sdk/
├── index.ts              # Public API exports
├── core/                 # Internal infrastructure  
│   ├── http/            # HTTP client and request handling
│   ├── errors.ts        # Error types and handling
│   └── logger.ts        # Logging configuration
└── resources/           # API resource implementations
    ├── users/           # User management
    ├── magnets/         # Torrent/magnet handling
    ├── links/           # Link unlocking
    └── hosts/           # Host information

Public API Surface

The SDK exposes a clean, stable API via the Alldebrid class:

  • User Resource: client.user.* - User info, saved links, recent links
  • Magnet Resource: client.magnet.* - List, get, upload, delete, restart
  • Link Resource: client.link.* - Get info, unlock premium links
  • Host Resource: client.host.* - List hosts, domains, priorities

Internal Implementation

  • HTTP client, logger, and error mapping are private
  • Resource classes are internal; only their methods are exposed
  • Type-safe with Zod schemas for all API responses

End-to-End Tests

These tests call the real AllDebrid API to validate responses against the SDK schemas. They are opt-in and skipped by default.

  • Local run:
ALLDEBRID_API_KEY=your_key ALLDEBRID_E2E=1 pnpm test
  • Or use the helper script (Linux CI runners):
ALLDEBRID_API_KEY=your_key pnpm test:e2e

CI recommendation (GitHub Actions):

jobs:
  e2e:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: pnpm/action-setup@v4
        with:
          version: 10
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: 'pnpm'
      - run: pnpm install --frozen-lockfile
      - run: pnpm build && pnpm typecheck && pnpm lint
      - name: Run E2E tests against AllDebrid API
        run: pnpm test:e2e
        env:
          ALLDEBRID_API_KEY: ${{ secrets.ALLDEBRID_API_KEY }}

Notes:

  • Tests only perform read/inspect calls (no destructive actions).
  • If the API payload shape changes, Zod parsing fails and CI will fail, alerting you to adjust schemas.