Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

marzban-sdk

Ilmar7786180MIT1.3.3TypeScript support: included

The Marzban SDK is a fully typed client library for interacting with the Marzban API. It works in both browser and Node.js environments

marzban-sdk, marzban, marzban api, marzban api client, marzban vpn, marzban vpn api, marzban vpn api client, vpn, http-client, api-client, vpn, proxy, shadowsocks, v2ray, xray, trojan, wireguard, vmess, vless, hysteria, tuic, rest-api, http, networking

readme

MarzbanSDK

🚀 MarzbanSDK

npm version npm downloads npm downloads npm license github starts

MarzbanSDK is a fully typed client library for interacting with the Marzban API. It supports both browser and Node.js environments, providing seamless integration and enhanced developer experience.

📖 Table of Contents

✨ Features

  • Full TypeScript Support – Schema definitions for all parameters, responses, and methods.
  • 🔄 Automatic Token Refresh – Keeps your session alive without manual intervention.
  • 🔁 Retry Mechanism – Ensures resilience against network failures.
  • 🛠️ Comprehensive API Support – Access all Marzban API features.
  • 📡 WebSocket Support – Real-time log streaming from core services and nodes.

📦 Installation

Install MarzbanSDK via npm:

npm install marzban-sdk

Or using yarn:

yarn add marzban-sdk

🚀 Quick Start

import { MarzbanSDK, Config } from "marzban-sdk";

const config: Config = {
  baseUrl: "https://api.example.com",
  username: "your-username",
  password: "your-password",
  retries: 3, // Option. default 3
  token: 'token' // Option
};

const sdk = new MarzbanSDK(config);

// Fetch user details
sdk.user.getUserById("user-id").then((user) => {
  console.log(user);
});

// get an authorization token
sdk.getAuthToken().then((token) => {
  console.log(token)
});

🔍 How It Works

1️⃣ Full Typing and Schema

MarzbanSDK provides full TypeScript typing and schema definitions for all API methods, parameters, and responses.

2️⃣ Generated Sources

The SDK is auto-generated from the OpenAPI specification, ensuring it stays up-to-date with API changes.

  • The entry point for the SDK is the MarzbanSDK class.
  • All API methods are dynamically generated based on the OpenAPI schema.

📚 API Documentation

For detailed API reference, visit the API Documentation.

📡 WebSocket Support

MarzbanSDK supports WebSocket for real-time log streaming.
You can receive logs from both the core server and individual nodes.

For more details, check the WebSocket Guide.

🤝 Contributing

We welcome contributions! If you'd like to improve MarzbanSDK, please:

  1. Fork the repository 🚀
  2. Create a new branch 🔧
  3. Submit a pull request 🎉

For details, check our Contribution Guidelines.

📜 License

This project is licensed under the MIT License.

⭐ Support the Project

If you find marzban-sdk useful, please give it a star on GitHub! It helps us stay motivated and grow the project.