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 🙏

© 2026 – Pkg Stats / Ryan Hefner

filebrowser-sdk

v1.0.2

Published

Unofficial TypeScript SDK for FileBrowser (filebrowser.org) — auth, files, users, shares.

Readme

filebrowser-sdk

Unofficial TypeScript SDK for FileBrowser — the self-hosted web file manager.

Supports: Auth · File Operations · Directory Listing · User Management · Share Links


Installation

npm install filebrowser-sdk
# or
yarn add filebrowser-sdk
# or
pnpm add filebrowser-sdk

Quick Start

import { FileBrowserSDK } from 'filebrowser-sdk';

const sdk = await FileBrowserSDK.create({
  baseURL: 'https://files.example.com',
  username: 'admin',
  password: 'admin123',
});

// List root directory
const dir = await sdk.files.list('/');
console.log(dir.items);

That's it. The SDK handles login, token storage, and auto-relogin automatically.


API Reference

FileBrowserSDK.create(config)

Creates and initializes the SDK (logs in automatically).

const sdk = await FileBrowserSDK.create({
  baseURL: 'https://files.example.com', // your FileBrowser URL
  username: 'admin',
  password: 'yourpassword',
});

sdk.auth

// Manual login (not needed if you use FileBrowserSDK.create)
const token = await sdk.auth.login('admin', 'password');

// Get current JWT token
const token = sdk.auth.getToken();

// Logout (clears stored token)
sdk.auth.logout();

sdk.files

List directory

const root = await sdk.files.list('/');
console.log(root.items);        // FileItem[]
console.log(root.numDirs);      // number
console.log(root.numFiles);     // number

const sub = await sdk.files.list('/documents');

Upload file

import fs from 'fs';

// From Buffer
const buffer = fs.readFileSync('./report.pdf');
await sdk.files.upload('/documents/report.pdf', buffer);

// With override (overwrite if exists)
await sdk.files.upload('/documents/report.pdf', buffer, { override: true });

// From string content
await sdk.files.upload('/notes/hello.txt', 'Hello World!', { override: true });

Download file

// As Buffer
const buffer = await sdk.files.download('/documents/report.pdf');
fs.writeFileSync('./local-report.pdf', buffer);

// As stream (recommended for large files)
const stream = await sdk.files.downloadStream('/videos/movie.mp4');
stream.pipe(fs.createWriteStream('./movie.mp4'));

Delete file or directory

await sdk.files.delete('/documents/old-report.pdf');
await sdk.files.delete('/old-folder');

Move / Rename

await sdk.files.move('/documents/old-name.txt', {
  destination: '/documents/new-name.txt',
});

// Move to different folder
await sdk.files.move('/documents/file.txt', {
  destination: '/archive/file.txt',
  override: true,
});

Copy

await sdk.files.copy('/documents/template.docx', {
  destination: '/projects/report.docx',
});

Create directory

await sdk.files.mkdir('/new-folder');
await sdk.files.mkdir('/documents/2024/january');

sdk.users (Admin only)

List all users

const users = await sdk.users.list();
console.log(users); // User[]

Get user by ID

const user = await sdk.users.get(1);
console.log(user.username);

Create user

const newUser = await sdk.users.create({
  username: 'john',
  password: 'secret123',
  scope: '.',
  locale: 'en',
  viewMode: 'list',
  singleClick: false,
  hideDotfiles: false,
  dateFormat: false,
  perm: {
    admin: false,
    execute: false,
    create: true,
    rename: true,
    modify: true,
    delete: true,
    share: true,
    download: true,
  },
  commands: [],
  sorting: { by: 'name', asc: true },
  rules: [],
});

Update user

// Only pass fields you want to change
await sdk.users.update(2, {
  password: 'newpassword',
  perm: {
    admin: false,
    execute: false,
    create: true,
    rename: false,
    modify: false,
    delete: false,
    share: false,
    download: true,
  },
});

Delete user

await sdk.users.delete(2);

sdk.shares

List all shares

const shares = await sdk.shares.list();
console.log(shares); // Share[]

Create share link

// No expiry
const share = await sdk.shares.create({
  path: '/documents/report.pdf',
});

// Expires in 7 days
const share = await sdk.shares.create({
  path: '/documents/report.pdf',
  expires: '7',
  unit: 'days',
});

// Password protected
const share = await sdk.shares.create({
  path: '/documents/secret.pdf',
  password: 'mypassword',
  expires: '24',
  unit: 'hours',
});

// Get the public URL
const url = sdk.shares.shareURL(sdk.getBaseURL(), share.hash);
console.log(url); // https://files.example.com/share/abc123

Delete share

await sdk.shares.delete('abc123hash');

Error Handling

import { FileBrowserSDK, FileBrowserError } from 'filebrowser-sdk';

try {
  const sdk = await FileBrowserSDK.create({
    baseURL: 'https://files.example.com',
    username: 'admin',
    password: 'wrongpassword',
  });
} catch (err) {
  if (err instanceof FileBrowserError) {
    console.error(`HTTP ${err.status}: ${err.message}`);
  }
}

TypeScript Types

All types are exported and fully documented:

import type {
  FileBrowserConfig,
  FileItem,
  DirectoryListing,
  User,
  UserPermissions,
  Share,
  CreateSharePayload,
  UploadOptions,
  MoveOrCopyOptions,
} from 'filebrowser-sdk';

Notes

  • This is an unofficial SDK — FileBrowser does not have official API documentation.
  • Auth uses the X-Auth header (not Authorization: Bearer).
  • Token is automatically refreshed if a 401 is received mid-session.
  • Tested against FileBrowser v2.x (filebrowser/filebrowser).

License

MIT