PHPackages                             martincamen/nzbget-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. martincamen/nzbget-php

ActiveLibrary[API Development](/categories/api)

martincamen/nzbget-php
======================

PHP SDK for NZBGet JSON-RPC API

1.0.1(6mo ago)041MITPHPPHP ^8.3

Since Dec 22Pushed 6mo agoCompare

[ Source](https://github.com/MartinCamen/nzbget-php)[ Packagist](https://packagist.org/packages/martincamen/nzbget-php)[ Docs](https://github.com/martincamen/nzbget-php)[ RSS](/packages/martincamen-nzbget-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (7)Versions (4)Used By (1)

NZBGet PHP SDK
==============

[](#nzbget-php-sdk)

A PHP SDK for the NZBGet JSON-RPC API.

Requirements
------------

[](#requirements)

- PHP 8.2+

Installation
------------

[](#installation)

```
composer require martincamen/nzbget-php
```

Usage
-----

[](#usage)

```
use NZBGet\NZBGet;

$nzbget = new NZBGet(
    host: 'localhost',
    port: 6789,
    username: 'admin',
    password: 'secret',
    useHttps: false,
    timeout: 30,
);

$version = $nzbget->program()->version();
$history = $nzbget->history()->get();
```

Working with Collections
------------------------

[](#working-with-collections)

The SDK returns typed DTOs and collections:

```
// Get history as a typed collection
$history = $nzbget->history()->get();

// Iterate with typed items
foreach ($history as $item) {
    echo $item->nzbName;  // string
    echo $item->status;   // string
    echo $item->health;   // int
    echo $item->dupeMode; // DupeMode enum
}

// Collection methods
$first = $history->first();     // ?HistoryItem
$last = $history->last();       // ?HistoryItem
$found = $history->find(123);   // ?HistoryItem by ID
$count = $history->count();     // int
$isEmpty = $history->isEmpty(); // bool

// Filter items
$movies = $history->filter(fn($item) => $item->category === 'movies');

// Map collection
$names = $history->map(fn($item) => $item->nzbName);

// Convert to array
$array = $history->toArray();
```

Using Enums
-----------

[](#using-enums)

The SDK provides typed enums for commands and modes:

```
use NZBGet\Data\Enums\DupeMode;
use NZBGet\Data\Enums\ServerCounter;

// Set duplicate mode with enum
$nzbget->history()->setDupeMode([1, 2], DupeMode::Force);

// Available DupeMode values
DupeMode::Score; // 'SCORE'
DupeMode::All;   // 'ALL'
DupeMode::Force; // 'FORCE'

// Reset server volume counter with enum
$nzbget->status()->resetServerVolume(1, ServerCounter::Custom);

// Available ServerCounter values
ServerCounter::Custom; // Reset custom counter only
ServerCounter::All;    // Reset all counters
```

Error Handling
--------------

[](#error-handling)

The SDK throws specific exceptions for different error types:

```
use NZBGet\Exceptions\AuthenticationException;
use NZBGet\Exceptions\ConnectionException;
use NZBGet\Exceptions\JsonRpcException;

try {
    $version = $nzbget->program()->version();
} catch (AuthenticationException $e) {
    // Invalid username or password
} catch (ConnectionException $e) {
    // Could not connect to the server
} catch (JsonRpcException $e) {
    // JSON-RPC error from NZBGet
    echo $e->rpcCode;    // Error code
    echo $e->getMessage(); // Error message
}
```

Testing
-------

[](#testing)

The SDK provides testing utilities for easy mocking:

```
use NZBGet\Testing\NZBGetFake;
use NZBGet\Testing\Factories\HistoryItemFactory;
use NZBGet\Testing\Factories\QueueGroupFactory;
use NZBGet\Testing\Factories\StatusFactory;
use PHPUnit\Framework\Attributes\Test;

class MyTest extends TestCase
{
    #[Test]
    public function itDisplaysHistory(): void
    {
        // Create a fake NZBGet instance
        $fake = new NZBGetFake([
            'history' => HistoryItemFactory::new()->count(5)->makeArray(),
            'status'  => StatusFactory::new()->makeArray(),
            'version' => '21.1',
        ]);

        // Use it in your code
        $history = $fake->history()->get();

        // Assert calls were made
        $fake->assertCalled('history');
        $fake->assertCalledWith('history', [false]);
        $fake->assertNotCalled('shutdown');
        $fake->assertCalledTimes('history', 1);
    }

    #[Test]
    public function itCanHideItems(): void
    {
        $fake = new NZBGetFake();

        $fake->history()->hide([1, 2, 3]);

        $fake->assertCalledWith('editqueue', ['HistoryDelete', 0, '', [1, 2, 3]]);
    }
}
```

### Using Factories

[](#using-factories)

```
use NZBGet\Testing\Factories\HistoryItemFactory;
use NZBGet\Testing\Factories\QueueGroupFactory;

// Create a single item
$item = HistoryItemFactory::new()->make();

// Create multiple items
$collection = HistoryItemFactory::new()->count(5)->make();

// Create with custom attributes
$item = HistoryItemFactory::new()
    ->withAttributes([
        'NZBID'    => 123,
        'Category' => 'movies',
        'Status'.  => 'SUCCESS/ALL',
    ])
    ->make();

// Get raw array data (for API mocking)
$data = HistoryItemFactory::new()->count(3)->makeArray();
```

Available Actions
-----------------

[](#available-actions)

### ProgramActions

[](#programactions)

MethodDescription`version()`Get the NZBGet version`shutdown()`Shutdown the NZBGet server`reload()`Reload the configuration### StatusActions

[](#statusactions)

MethodDescription`get()`Get current server status`serverVolumes()`Get server volume statistics`resetServerVolume(int $serverId, ServerCounter $counter)`Reset server volume counter### DownloadActions

[](#downloadactions)

MethodDescription`pause()`Pause all downloads`resume()`Resume all downloads`pausePost()`Pause post-processing`resumePost()`Resume post-processing`pauseScan()`Pause directory scanning`resumeScan()`Resume directory scanning`rate(int $limitKbPerSecond)`Set speed limit (Limit disabled by default (`0`))`scheduleResume(int $secondsToWait)`Schedule automatic resume### QueueActions

[](#queueactions)

MethodDescription`listGroups(int $logEntries = 0)`List all queue groups`pause(array $ids)`Pause specific items`resume(array $ids)`Resume specific items`delete(array $ids)`Delete specific items`setPriority(array $ids, int $priority)`Set priority`setCategory(array $ids, string $category)`Set category`setName(array $ids, string $name)`Rename items`moveTop(array $ids)`Move to top of queue`moveBottom(array $ids)`Move to bottom of queue### HistoryActions

[](#historyactions)

MethodDescription`get(bool $includeHidden = false)`Get history items`hide(array $ids)`Hide items (soft delete)`delete(array $ids)`Permanently delete items`returnToQueue(array $ids)`Return items to queue`process(array $ids)`Re-run post-processing`redownload(array $ids)`Redownload items`setName(array $ids, string $name)`Rename items`setDupeKey(array $ids, string $key)`Set duplicate key`setDupeScore(array $ids, int $score)`Set duplicate score`setDupeMode(array $ids, DupeMode $mode)`Set duplicate mode`markBad(array $ids)`Mark as bad`markGood(array $ids)`Mark as good`markSuccess(array $ids)`Mark as successLicense
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance67

Regular maintenance activity

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

192d ago

PHP version history (2 changes)1.0.0PHP ^8.2

1.0.1PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8720813?v=4)[Martin Camen](/maintainers/MartinCamen)[@MartinCamen](https://github.com/MartinCamen)

---

Top Contributors

[![MartinCamen](https://avatars.githubusercontent.com/u/8720813?v=4)](https://github.com/MartinCamen "MartinCamen (5 commits)")

---

Tags

apisdkjson-rpcnzbgetusenet

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/martincamen-nzbget-php/health.svg)

```
[![Health](https://phpackages.com/badges/martincamen-nzbget-php/health.svg)](https://phpackages.com/packages/martincamen-nzbget-php)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k9.5M88](/packages/openai-php-laravel)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M46](/packages/tencentcloud-tencentcloud-sdk-php)[resend/resend-php

Resend PHP library.

617.2M42](/packages/resend-resend-php)[checkout/checkout-sdk-php

Checkout.com SDK for PHP

563.6M13](/packages/checkout-checkout-sdk-php)[files.com/files-php-sdk

Files.com PHP SDK

2481.1k](/packages/filescom-files-php-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
