MarzbanSDK

Introduction

The complete TypeScript SDK for Marzban — fully typed API coverage plus auth, retries, WebSocket streaming and webhooks. Node.js, Bun, Deno, and the browser.

MarzbanSDK is a complete, production-grade TypeScript SDK for building Marzban integrations. Beyond fully typed coverage of the entire API, it bundles the infrastructure a real integration needs — authentication with transparent token refresh, retries, WebSocket log streaming, webhook verification, and runtime validation — and behaves identically in Node.js, Bun, Deno, and the browser.

Features

Module overview

ModuleAccessDescription
Userssdk.userCreate, update, query, and manage users
Adminssdk.adminManage admin accounts
Nodessdk.nodeAdd, configure, and monitor nodes
Systemsdk.systemStats, inbounds, and proxy host config
Coresdk.coreXray core stats, config, and restart
Subscriptionssdk.subscriptionPublic subscription endpoints
User Templatessdk.userTemplateReusable user configuration templates
Webhookssdk.webhookIncoming event handling and verification
Logssdk.logsReal-time WebSocket log streaming

Quick example

import { createMarzbanSDK, formatBytes, humanRemaining } from 'marzban-sdk'

const sdk = await createMarzbanSDK({
  baseUrl: 'https://vpn.example.com',
  username: 'admin',
  password: 'secret',
})

// List active users
const { users, total } = await sdk.user.getUsers({ status: 'active' })
console.log(`${total} active users`)

for (const user of users) {
  const dataLeft = formatBytes((user.data_limit ?? 0) - user.used_traffic)
  const timeLeft = user.expire ? humanRemaining(user.expire * 1000) : '∞'
  console.log(`${user.username} — ${dataLeft} left, expires ${timeLeft}`)
}

On this page