{"id":18665325,"url":"https://github.com/robertklep/qbittorrent","last_synced_at":"2025-04-11T22:31:03.123Z","repository":{"id":57700361,"uuid":"468703498","full_name":"robertklep/qbittorrent","owner":"robertklep","description":"Node.js qBittorrent API client","archived":false,"fork":false,"pushed_at":"2022-09-05T14:45:31.000Z","size":15,"stargazers_count":19,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T01:53:18.874Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robertklep.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-11T10:21:34.000Z","updated_at":"2025-03-22T06:24:49.000Z","dependencies_parsed_at":"2022-09-26T21:10:51.530Z","dependency_job_id":null,"html_url":"https://github.com/robertklep/qbittorrent","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertklep%2Fqbittorrent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertklep%2Fqbittorrent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertklep%2Fqbittorrent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertklep%2Fqbittorrent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robertklep","download_url":"https://codeload.github.com/robertklep/qbittorrent/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248489538,"owners_count":21112594,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T08:27:12.829Z","updated_at":"2025-04-11T22:31:02.690Z","avatar_url":"https://github.com/robertklep.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# qBittorrent v2 API client\n\nImplements almost all of the methods of the current (v2.8.3) qBittorrent [WebUI API](https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)).\n\nDisclaimer: not all of the API methods have been tested.\n\n## Installation\n\n```\nnpm install @robertklep/qbittorrent\n```\n\n## Examples\n\n#### Instantiating\n\nTypeScript:\n```typescript\nimport { qBittorrentClient } from '@robertklep/qbittorrent';\n\nconst client = new qBittorrentClient('http://127.0.0.1:8080', 'username', 'password');\n```\n\nJavaScript:\n```javascript\nconst { qBittorrentClient } = require('@robertklep/qbittorrent');\n\nconst client = new qBittorrentClient('http://127.0.0.1:8080', 'username', 'password');\n```\n\nThere is no need to explicitly call `client.auth.login()`, the client will log in automatically on the first API call.\n\n#### Getting the server version\n\n```typescript\nconst info = await client.app.version();\n```\n\n#### Adding torrents\n\nAdd a single torrent by URL:\n```typescript\nconst res = await client.torrents.add('https://distrowatch.com/dwres/torrents/xubuntu-20.04.4-desktop-amd64.iso.torrent');\n\n// also works for Magnet URI's\nconst res = await client.torrents.add('magnet:?xt=urn:btih:dd8255ecdc7ca55fb0bbf81323d87062db1f6d1c\u0026dn=Big+Buck+Bunny\u0026tr=udp%3A%2F%2Fexplodie.org%3A6969\u0026tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969\u0026tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337\u0026tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969\u0026tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337\u0026tr=wss%3A%2F%2Ftracker.btorrent.xyz\u0026tr=wss%3A%2F%2Ftracker.fastcast.nz\u0026tr=wss%3A%2F%2Ftracker.openwebtorrent.com\u0026ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F\u0026xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fbig-buck-bunny.torrent')\n```\n\nAdd multiple torrents by URL:\n```typescript\nconst res = await client.torrents.add([\n  'https://distrowatch.com/dwres/torrents/xubuntu-20.04.4-desktop-amd64.iso.torrent',\n  'https://distrowatch.com/dwres/torrents/ubuntu-budgie-20.04.4-desktop-amd64.iso.torrent'\n]);\n```\n\nAdd by file contents:\n```typescript\nimport { qBittorrentClient, TorrentAddParameters } from '@robertklep/qbittorrent';\nimport { readFile }                   from 'fs/promises';\n\nconst res = await client.torrents.add(\u003cTorrentAddParameters\u003e{\n  torrents: { // TorrentFile[] | TorrentFile\n    buffer : await readFile('xubuntu-20.04.4-desktop-amd64.iso.torrent')\n  },\n  // start this torrent in a paused state (see Torrent type for options)\n  paused: true\n});\n```\n\n#### Searching torrents\n\n(your qBittorrent installation needs to support search for this to work)\n\n```typescript\nconst wait = (ms : number) =\u003e new Promise(r =\u003e setTimeout(r, ms));\n\n// start a search\nconst id = await client.search.start('linux');\n\n// run the search for 20 seconds, check status every second\nfor (let i = 0; i \u003c 20; i++) {\n  const { status, total } = await client.search.status(id) as TorrentSearchStatus;\n  console.log(`Status: ${ status }, total number of results so far: ${ total }`);\n  await wait(1000);\n}\n\n// retrieve the results\nconsole.log( await client.search.results(id) );\n\n// delete the search\nawait client.search.delete(id);\n```\n\n## Documentation\n\nThe structure of this module follows the structure and naming of the [qBittorrent WebUI API](https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)) methods.\n\nFor example, the [Authentication `login` method](https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#authentication) is accessible as `client.auth.login()`\n\n#### Types\n```\nexport declare type TorrentFile = {\n    filename?: string;\n    name?: string;\n    buffer: Buffer | string;\n    content_type: string;\n};\nexport declare type TorrentAddParameters = {\n    urls: string[] | string;\n    torrents: TorrentFile[] | TorrentFile;\n    savepath: string;\n    cookie: string;\n    category: string;\n    tags: string[] | string;\n    skip_checking: boolean;\n    paused: boolean;\n    root_folder: string;\n    rename: string;\n    upLimit: number;\n    dlLimit: number;\n    ratioLimit: number;\n    seedingTimeLimit: number;\n    autoTMM: number;\n    sequentialDownload: boolean;\n    firstLastPiecePrio: boolean;\n};\nexport declare type TorrentInfoParameters = {\n    filter: 'all' | 'downloading' | 'seeding' | 'completed' | 'paused' | 'active' | 'inactive' | 'resumed' | 'stalled' | 'stalled_uploading' | 'stalled_downloading' | 'errored';\n    category: string;\n    tag: string;\n    sort: string;\n    reverse: boolean;\n    limit: number;\n    offset: number;\n    hashes: string[] | string;\n};\nexport declare type TorrentSearchStatus = {\n    id: number;\n    status: string;\n    total: number;\n};\nexport declare type TorrentSearchResult = {\n    descrLink: string;\n    fileName: string;\n    fileSize: number;\n    fileUrl: string;\n    nbLeechers: number;\n    nbSeeders: number;\n    siteUrl: string;\n};\nexport declare class qBittorrentClient {\n    #private;\n    auth: qBittorrentAuthClient;\n    app: qBittorrentAppClient;\n    log: qBittorrentLogClient;\n    sync: qBittorrentSyncClient;\n    transfer: qBittorrentTransferClient;\n    torrents: qBittorrentTorrentsClient;\n    search: qBittorrentSearchClient;\n    constructor(url: string, username?: string, password?: string);\n    request(method: string, data?: RequestData, options?: RequestOptions): Promise\u003cany\u003e;\n}\ndeclare class qBittorrentSubClient {\n    protected client: qBittorrentClient;\n    constructor(client: qBittorrentClient);\n}\ndeclare class qBittorrentAuthClient extends qBittorrentSubClient {\n    login(): Promise\u003cany\u003e;\n    logout(): Promise\u003cany\u003e;\n}\ndeclare class qBittorrentAppClient extends qBittorrentSubClient {\n    version(): Promise\u003cany\u003e;\n    webapiVersion(): Promise\u003cany\u003e;\n    buildInfo(): Promise\u003cany\u003e;\n    shutdown(): Promise\u003cany\u003e;\n    preferences(): Promise\u003cany\u003e;\n    setPreferences(prefs: RequestData): Promise\u003cany\u003e;\n    defaultSavePath(): Promise\u003cany\u003e;\n}\ndeclare class qBittorrentLogClient extends qBittorrentSubClient {\n    main(params: RequestData): Promise\u003cany\u003e;\n    peers(last_known_id?: number): Promise\u003cany\u003e;\n}\ndeclare class qBittorrentSyncClient extends qBittorrentSubClient {\n    maindata(rid?: number): Promise\u003cany\u003e;\n    torrentPeers(hash: string, rid?: number): Promise\u003cany\u003e;\n}\ndeclare class qBittorrentTransferClient extends qBittorrentSubClient {\n    info(): Promise\u003cany\u003e;\n    speedLimitsMode(): Promise\u003cany\u003e;\n    toggleSpeedLimitsMode(): Promise\u003cany\u003e;\n    downloadLimit(): Promise\u003cany\u003e;\n    setDownloadLimit(limit: number): Promise\u003cany\u003e;\n    uploadLimit(): Promise\u003cany\u003e;\n    setUploadLimit(limit: number): Promise\u003cany\u003e;\n    banPeers(peers: string[] | string): Promise\u003cany\u003e;\n}\ndeclare class qBittorrentTorrentsClient extends qBittorrentSubClient {\n    info(params?: Partial\u003cTorrentInfoParameters\u003e): Promise\u003cany\u003e;\n    properties(hash: string): Promise\u003cany\u003e;\n    trackers(hash: string): Promise\u003cany\u003e;\n    webseeds(hash: string): Promise\u003cany\u003e;\n    files(hash: string, indexes?: string[] | string | number): Promise\u003cany\u003e;\n    pieceStates(hash: string): Promise\u003cany\u003e;\n    pieceHashes(hash: string): Promise\u003cany\u003e;\n    pause(hashes: string[] | string): Promise\u003cany\u003e;\n    resume(hashes: string[] | string): Promise\u003cany\u003e;\n    delete(hashes: string[] | string, deleteFiles?: boolean): Promise\u003cany\u003e;\n    recheck(hashes: string[] | string): Promise\u003cany\u003e;\n    reannounce(hashes: string[] | string): Promise\u003cany\u003e;\n    editTracker(hash: string, origUrl: string, newUrl: string): Promise\u003cany\u003e;\n    removeTracker(hash: string, urls: string[] | string): Promise\u003cany\u003e;\n    addPeers(hashes: string[] | string, peers: string[] | string): Promise\u003cany\u003e;\n    increasePrio(hashes: string[] | string): Promise\u003cany\u003e;\n    decreasePrio(hashes: string[] | string): Promise\u003cany\u003e;\n    topPrio(hashes: string[] | string): Promise\u003cany\u003e;\n    bottomPrio(hashes: string[] | string): Promise\u003cany\u003e;\n    filePrio(hash: string, id: string[] | string, priority: number): Promise\u003cany\u003e;\n    downloadLimit(hashes: string[] | string): Promise\u003cany\u003e;\n    setDownloadLimit(hashes: string[] | string, limit: number): Promise\u003cany\u003e;\n    setShareLimits(hashes: string[] | string, ratioLimit?: number, seedingTimeLimit?: number): Promise\u003cany\u003e;\n    uploadLimit(hashes: string[] | string): Promise\u003cany\u003e;\n    setUploadLimit(hashes: string[] | string, limit: number): Promise\u003cany\u003e;\n    setLocation(hashes: string[] | string, location: string): Promise\u003cany\u003e;\n    rename(hash: string, name: string): Promise\u003cany\u003e;\n    setCategory(hashes: string[] | string, category: string): Promise\u003cany\u003e;\n    categories(): Promise\u003cany\u003e;\n    createCategory(category: string, savePath: string): Promise\u003cany\u003e;\n    editCategory(category: string, savePath: string): Promise\u003cany\u003e;\n    removeCategories(categories: string[] | string): Promise\u003cany\u003e;\n    addTags(hashes: string[] | string, tags: string[] | string): Promise\u003cany\u003e;\n    removeTags(hashes: string[] | string, tags: string[] | string): Promise\u003cany\u003e;\n    tags(): Promise\u003cany\u003e;\n    createTags(tags: string[] | string): Promise\u003cany\u003e;\n    deleteTags(tags: string[] | string): Promise\u003cany\u003e;\n    setAutoManagement(hashes: string[] | string, enable?: boolean): Promise\u003cany\u003e;\n    toggleSequentialDownload(hashes: string[]): Promise\u003cany\u003e;\n    toggleFirstLastPiecePrio(hashes: string[]): Promise\u003cany\u003e;\n    setForceStart(hashes: string[] | string, value?: boolean): Promise\u003cany\u003e;\n    setSuperSeeding(hashes: string[] | string, value?: boolean): Promise\u003cany\u003e;\n    renameFile(hash: string, oldPath: string, newPath: string): Promise\u003cany\u003e;\n    renameFolder(hash: string, oldPath: string, newPath: string): Promise\u003cany\u003e;\n    add(torrent: TorrentAddParameters | string[] | string): Promise\u003cany\u003e;\n}\ndeclare class qBittorrentSearchClient extends qBittorrentSubClient {\n    start(pattern: string, plugins?: string[] | string, category?: string[] | string): Promise\u003cnumber\u003e;\n    stop(id: number): Promise\u003cany\u003e;\n    status(id?: number): Promise\u003cTorrentSearchStatus[] | TorrentSearchStatus\u003e;\n    results(id: number, limit?: number, offset?: number): Promise\u003cTorrentSearchResult[]\u003e;\n    delete(id: number): Promise\u003cany\u003e;\n    plugins(): Promise\u003cany\u003e;\n    installPlugin(sources: string[] | string): Promise\u003cany\u003e;\n    uninstallPlugin(names: string[] | string): Promise\u003cany\u003e;\n    enablePlugin(names: string[] | string, enable: boolean): Promise\u003cany\u003e;\n    updatePlugins(): Promise\u003cany\u003e;\n}\n```\n\n#### Methods\n\nMost methods that accept parameters that are either a single ór multiple values, like `hashes`, will accept both strings and arrays of strings. When passing as a string, make sure you use the correct separator when passing multiple values (usually `|`), or just pass the values as an array and the client will take care of concatenating the values properly.\n\nAll methods are async (return a Promise) and will thrown an error when the backend returns an non-200 status code. Please refer to the WebUI API documentation for full explanation of every method and their parameters.\n\nList of implemented methods:\n```\nclient.auth.login()\nclient.auth.logout()\n\nclient.app.version()\nclient.app.webapiVersion()\nclient.app.buildInfo()\nclient.app.shutdown()\nclient.app.preferences()\nclient.app.setPreferences(prefs : RequestData)\nclient.app.defaultSavePath()\n\nclient.log.main(params : RequestData)\nclient.log.peers(last_known_id = -1)\n\nclient.sync.maindata(rid = 0)\nclient.sync.torrentPeers(hash : string, rid = 0)\n\nclient.transfer.info()\nclient.transfer.speedLimitsMode()\nclient.transfer.toggleSpeedLimitsMode()\nclient.transfer.downloadLimit()\nclient.transfer.setDownloadLimit(limit : number)\nclient.transfer.uploadLimit()\nclient.transfer.setUploadLimit(limit : number)\nclient.transfer.banPeers(peers : string[] | string)\n\ninfo(params : Partial\u003cTorrentInfoParameters\u003e = {}) {\nclient.torrents.properties(hash : string)\nclient.torrents.trackers(hash : string)\nclient.torrents.webseeds(hash : string)\nclient.torrents.files(hash : string, indexes : string[] | string = '')\nclient.torrents.pieceStates(hash : string)\nclient.torrents.pieceHashes(hash : string)\nclient.torrents.pause(hashes : string[] | string)\nclient.torrents.resume(hashes : string[] | string)\nclient.torrents.delete(hashes : string[] | string, deleteFiles = false)\nclient.torrents.recheck(hashes : string[] | string)\nclient.torrents.reannounce(hashes : string[] | string)\nclient.torrents.editTracker(hash : string, origUrl : string, newUrl : string)\nclient.torrents.removeTracker(hash : string, urls : string[] | string)\nclient.torrents.addPeers(hashes : string[] | string, peers : string[] | string)\nclient.torrents.increasePrio(hashes : string[] | string)\nclient.torrents.decreasePrio(hashes : string[] | string)\nclient.torrents.topPrio(hashes : string[] | string)\nclient.torrents.bottomPrio(hashes : string[] | string)\nclient.torrents.filePrio(hash : string, id : string[] | string, priority : number)\nclient.torrents.downloadLimit(hashes : string[] | string)\nclient.torrents.setDownloadLimit(hashes : string[] | string, limit : number)\nclient.torrents.setShareLimits(hashes : string[] | string, ratioLimit = -1, seedingTimeLimit = -1)\nclient.torrents.uploadLimit(hashes : string[] | string)\nclient.torrents.setUploadLimit(hashes : string[] | string, limit : number)\nclient.torrents.setLocation(hashes : string[] | string, location : string)\nclient.torrents.rename(hash : string, name : string)\nclient.torrents.setCategory(hashes : string[] | string, category : string)\nclient.torrents.categories()\nclient.torrents.createCategory(category : string, savePath : string)\nclient.torrents.editCategory(category : string, savePath : string)\nclient.torrents.removeCategories(categories : string[] | string)\nclient.torrents.addTags(hashes : string[] | string, tags : string[] | string)\nclient.torrents.removeTags(hashes : string[] | string, tags : string[] | string)\nclient.torrents.tags()\nclient.torrents.createTags(tags : string[] | string)\nclient.torrents.deleteTags(tags : string[] | string)\nclient.torrents.setAutoManagement(hashes : string[] | string, enable = false)\nclient.torrents.toggleSequentialDownload(hashes : string[])\nclient.torrents.toggleFirstLastPiecePrio(hashes : string[])\nclient.torrents.setForceStart(hashes : string[] | string, value = false)\nclient.torrents.setSuperSeeding(hashes : string[] | string, value = false)\nclient.torrents.renameFile(hash : string, oldPath : string, newPath : string)\nclient.torrents.renameFolder(hash : string, oldPath : string, newPath : string)\nclient.torrents.add(torrent : Torrent | string[] | string)\n// TODO: client.torrents.addTrackers()\n\nclient.search.start( pattern : string, plugins : string[] | string = 'all', category : string[] | string = 'all' )\nclient.search.stop( id : number )\nclient.search.status( id? : number )\nclient.search.results( id : number, limit = 0, offset = 0 )\nclient.search.delete( id : number )\nclient.search.plugins()\nclient.search.installPlugin(sources : string[] | string)\nclient.search.uninstallPlugin(names : string[] | string)\nclient.search.enablePlugin(names : string[] | string, enable : boolean)\nclient.search.updatePlugins()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertklep%2Fqbittorrent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobertklep%2Fqbittorrent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertklep%2Fqbittorrent/lists"}