arr-sdk
v0.3.0
Published
Unified TypeScript SDK for Sonarr, Radarr, and Prowlarr
Maintainers
Readme
arr-sdk
Unified TypeScript SDK for Sonarr, Radarr, and Prowlarr APIs.
Features
- Full TypeScript support with types generated from official OpenAPI specs
- Native
fetchAPI (no dependencies) - Subpath exports for tree-shaking
- Async pagination helpers
- Comprehensive error handling
- Request/response hooks
Installation
npm install arr-sdkQuick Start
Sonarr
import { SonarrClient } from 'arr-sdk/sonarr'
const sonarr = new SonarrClient({
baseUrl: 'http://localhost:8989',
apiKey: 'your-api-key'
})
// Get all series
const series = await sonarr.series.getAll()
// Search for a series
const results = await sonarr.series.lookup('Breaking Bad')
// Add a series
const newSeries = await sonarr.series.create({
tvdbId: 81189,
title: 'Breaking Bad',
qualityProfileId: 1,
rootFolderPath: '/tv'
})Radarr
import { RadarrClient } from 'arr-sdk/radarr'
const radarr = new RadarrClient({
baseUrl: 'http://localhost:7878',
apiKey: 'your-api-key'
})
// Get all movies
const movies = await radarr.movie.getAll()
// Search for a movie
const results = await radarr.movie.lookup('The Matrix')
// Add a movie
const newMovie = await radarr.movie.create({
tmdbId: 603,
title: 'The Matrix',
qualityProfileId: 1,
rootFolderPath: '/movies'
})Prowlarr
import { ProwlarrClient } from 'arr-sdk/prowlarr'
const prowlarr = new ProwlarrClient({
baseUrl: 'http://localhost:9696',
apiKey: 'your-api-key'
})
// Get all indexers
const indexers = await prowlarr.indexer.getAll()
// Search across indexers
const results = await prowlarr.search.query({
query: 'ubuntu',
type: 'search'
})Configuration
import { SonarrClient } from 'arr-sdk/sonarr'
const client = new SonarrClient({
baseUrl: 'http://localhost:8989',
apiKey: 'your-api-key',
// Optional: custom timeout (default: 30000ms)
timeout: 60000,
// Optional: custom headers
headers: {
'X-Custom-Header': 'value'
},
// Optional: request/response hooks
onRequest: (config) => {
console.log('Request:', config.method, config.url.href)
},
onResponse: (response) => {
console.log('Response:', response.status)
},
onError: (error) => {
console.error('Error:', error.message)
}
})Pagination
For endpoints that return paginated results:
// Async generator for memory-efficient iteration
for await (const item of client.queue.getAll()) {
console.log(item)
}
// Or get all results at once
const allItems = await client.queue.getAllArray()Error Handling
import {
ArrError,
NotFoundError,
UnauthorizedError,
ValidationError
} from 'arr-sdk'
try {
await client.series.getById(99999)
} catch (error) {
if (error instanceof NotFoundError) {
console.log('Series not found')
} else if (error instanceof UnauthorizedError) {
console.log('Invalid API key')
} else if (error instanceof ValidationError) {
console.log('Validation errors:', error.errors)
} else if (error instanceof ArrError) {
console.log('API error:', error.statusCode, error.message)
}
}Breaking Changes
See CHANGELOG.md for a complete list of breaking changes.
Queue Options
The quality field in GetQueueOptions changed from number to number[]:
// Before (v0.1.x)
await client.queue.get({ quality: 1 })
// After (v0.2.0+)
await client.queue.get({ quality: [1] })Available Resources
Sonarr
series- Series managementepisode- Episode managementepisodeFile- Episode file managementcalendar- Calendar/upcoming episodes (includes iCal feed)queue- Download queuewanted- Missing and cutoff unmet episodeshistory- Activity historycommand- Commands (refresh, scan, manualImport, etc.)qualityProfile- Quality profilesqualityDefinition- Quality definitionsrootFolder- Root folderstag- Tagsindexer- Indexer configurationdownloadClient- Download client configurationimportList- Import listsnotification- Notificationsmetadata- Metadata providersrelease- Release search/grabblocklist- Blocklisted releasessystem- System info, health, logs, pingfilesystem- Browse filesystem pathsmediaCover- Download series cover imagesconfig- Host/UI/naming configuration
Radarr
movie- Movie managementcollection- Collection managementcalendar- Calendar/upcoming releases (includes iCal feed)queue- Download queuewanted- Missing and cutoff unmet movieshistory- Activity historycommand- Commands (refresh, scan, manualImport, etc.)qualityProfile- Quality profilesqualityDefinition- Quality definitionscustomFormat- Custom formatsrootFolder- Root folderstag- Tagsindexer- Indexer configurationdownloadClient- Download client configurationimportList- Import listsnotification- Notificationsmetadata- Metadata providersrelease- Release search/grabblocklist- Blocklisted releasessystem- System info, health, logs, pingfilesystem- Browse filesystem pathsmediaCover- Download movie cover imagesconfig- Host/UI/naming configuration
Prowlarr
indexer- Indexer managementindexerStats- Indexer statistics with filteringindexerProxy- Indexer proxiesapplication- Application connectionsappProfile- App sync profilessearch- Search across indexersnewznab- Newznab/Torznab protocol (caps, search, download)command- Commandshistory- Search historytag- TagsdownloadClient- Download clientsnotification- Notificationssystem- System info, health, logs, pingfilesystem- Browse filesystem pathslocalization- Localization stringsconfig- Configuration
Tree-Shaking
Import only what you need:
// Import only Sonarr (smaller bundle)
import { SonarrClient } from 'arr-sdk/sonarr'
// Import only Radarr
import { RadarrClient } from 'arr-sdk/radarr'
// Import only Prowlarr
import { ProwlarrClient } from 'arr-sdk/prowlarr'
// Or import everything
import { SonarrClient, RadarrClient, ProwlarrClient } from 'arr-sdk'Requirements
- Node.js >= 18.0.0 (uses native
fetch)
License
MIT
