Unifi API Client can be used to connect to the API of your Ubiquiti Unifi Controller
Go to file
Will Bradley b4ab8cf6d2 Making login/logout work as expected with newer controllers (persisting cookies within a client, except after login/logout) 2018-01-23 20:50:14 -08:00
examples add example for USG traffic statistics (#3) 2017-11-26 23:42:12 +01:00
src Making login/logout work as expected with newer controllers (persisting cookies within a client, except after login/logout) 2018-01-23 20:50:14 -08:00
.gitignore Added composer lock file 2015-11-21 16:09:00 +01:00
LICENSE Initial release of the Unifi API Client 2015-08-09 21:16:24 +02:00
README.md Fixed documentation 2015-11-21 16:00:12 +01:00
composer.json Initial release of the Unifi API Client 2015-08-09 21:16:24 +02:00
composer.lock Added composer lock file 2015-11-21 16:09:00 +01:00

README.md

Unifi API Client

Unifi API Client can be used to connect to the API of your Ubiquiti Unifi Controller. This client is build on top of Guzzle.

The code is tested against Unifi Controller version 4.6.6.

Installation

The API client can be installed with Composer:

composer require jorisvandesande/unifi-api-client

Or you can download the latest release at: https://github.com/jorisvandesande/unifi-api-client/releases

Usage

use JVDS\UnifiApiClient\Client;
use GuzzleHttp\Client as HttpClient;

$apiClient = new Client(new HttpClient(['base_uri' => 'https://127.0.0.1:8443']));
$apiClient->login('your_username', 'your_password');

// call supported methods via methods on the client
$apiClient->statistics('default');

// or call any API url via the get and post methods:
$apiClient->get('/api/self');
$apiClient->post('/api/s/default/cmd/stamgr', ['cmd' => 'block-sta', 'mac' => '01:01:01:01:01:01']);

// logout
$apiClient->logout();

Examples can be found in the examples directory. To run the examples, you must copy the config.example.php file to config.php and change the configuration to your needs.

Supported API calls

At the moment only a few API methods are implemented in the Client. Altough it is possible to use the get() and post() methods of the Client to call any API url, the goal is to support more methods.

License

MIT Licensed, see the LICENSE file.