iwalkalone/wgrest-api

A class to use wgrest API

Maintainers

Package info

codeberg.org/iwalkalone/wgrest-api.git

pkg:composer/iwalkalone/wgrest-api

Statistics

Installs: 13

Dependents: 0

Suggesters: 0

v1.0 2026-03-03 12:57 UTC

This package is not auto-updated.

Last update: 2026-03-04 11:44:55 UTC


README

Description

Class to use wgrest API and automate Wireguard.

Install

Install with composer:

composer require iwalkalone/wgrest-api

Or a specific version:

composer require iwalkalone/wgrest-api ^1.0

What supports now

For now it just implements adding and deleting peers.

How to use it

$wgrest = new \iwalkalone\WgRestApi([
    'bearer_token' => 'you-token',
    'base_uri' => 'http://127.0.0.1:8000',
]);
// To add a peer, we just have to pass interface, endpoint and a list of allowed ips
$data = $wgrest->addPeer('wg0', '1.2.3.4:12345', ['10.10.0.0/32']);
// $data contains the response in array format
// you should save url_safe_public_key to delete the peer in the future
// To delete a peer, we just have to pass interface and the public key we just saved
$url_safe_public_key = $data['url_safe_public_key'];
$data = $wgrest->deletePeer('wg0', $url_safe_public_key);