wg-easy-client
v1.1.1
Published
A Node.js client for managing WireGuard Easy instances via API
Maintainers
Readme
wg-easy-client
A Node.js client for managing wg-easy (docker hub) instance via API. This package allows you to create, delete, and manage WireGuard clients programmatically. It also includes an interactive CLI tool for testing API calls.
🚀 Features
- Manage WireGuard clients (create, delete, disable, list clients)
- Fully typed with TypeScript
- Auto-authentication (handles session expiration)
- CLI tool for testing API
- Supports ESM & CommonJS
📦 Installation
npm install wg-easy-client🚀 Usage
0️⃣ Setup .env
PASSWORD=YOUR_PASSWORD
WG_EASY_URL=YOUR_WG_EASY_URL1️⃣ Import and Use in Code
import { WgEasyClient } from 'wg-easy-client'
import dotenv from 'dotenv'
dotenv.config()
const client = new WgEasyClient()
void (async () => {
await client.createClient('test-client')
console.log(await client.getClients())
})()2️⃣ Run the CLI Tool
After installation, you can run the CLI tool to test the API:
PASSWORD=YOUR_PASSWORD WG_EASY_URL=YOUR_URL npx wg-easy-clior, if installed globally:
PASSWORD=YOUR_PASSWORD WG_EASY_URL=YOUR_URL wg-easy-cli🔧 API Methods
Create a Client
await client.createClient('my-client')Delete a Client
await client.deleteClient('client-id')Enable a Client
await client.enableClient('client-id')Disable a Client
await client.disableClient('client-id')Get All Clients
const clients = await client.getClients()Get Client ID by Name
const clientId = await client.getClientIdByName('my-client')🛠 Development
Run Locally in Dev Mode
npm run devBuild the Package
npm run buildTest the CLI Locally
node dist/cli.js📢 Contributing
Feel free to contribute! Fork, create a new branch, and submit a PR.
📝 License
This project is licensed under the MIT License.
