Skip to content

Commit 55843a5

Browse files
committed
UniFi API browser 2.0.7
- added support for UniFi OS-based controllers - included the version 1.1.47 of the PHP API client class
1 parent 4aceffc commit 55843a5

File tree

15 files changed

+638
-182
lines changed

15 files changed

+638
-182
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ This tool is for browsing data that is exposed through Ubiquiti's UniFi Controll
44

55
It comes bundled with a **PHP class for access to the UniFi Controller API**, which supports [more API endpoints](https://github.com/Art-of-WiFi/UniFi-API-client#methods-and-functions-supported) than the UniFi API browser tool does.
66

7-
If you plan to create your own PHP code leveraging the UniFi controller API, it is recommended to use the standalone version of the API client class which can be found here: https://github.com/Art-of-WiFi/UniFi-API-client
7+
If you plan on creating your own PHP code to leverage the UniFi controller API, it is recommended to use the standalone version of the API client class which can be found here: https://github.com/Art-of-WiFi/UniFi-API-client
88

99
You will find examples and detailed instructions there.
1010

1111
Please keep the following in mind:
1212

1313
- the API browser tool doesn't support all available data collections/API endpoints, see the list below of those that are currently supported
14-
- currently, versions 4.x.x and 5.x.x of the UniFi Controller software are supported (version 5.11.50 has been confirmed to work)
15-
- there is still work to be done to add/improve functionality and usability of this tool so suggestions/comments are welcome. Please use the github [issue](https://github.com/Art-of-WiFi/UniFi-API-browser/issues) list or the Ubiquiti Community forums (https://community.ubnt.com/t5/UniFi-Wireless/UniFi-API-browser-tool-released/m-p/1392651) to share your ideas/questions.
14+
- currently, versions 4.x.x and 5.x.x of the UniFi Controller software are supported (version 5.12.35 has been confirmed to work) as well as UniFi OS-based controllers (version 5.12.59 has been confirmed to work)
15+
- when accessing UniFi OS-based controllers (e.g. UDM PRO) through this tool, please read the remarks below regarding UniFi OS support
16+
- there is still work to be done to add/improve functionality and usability of this tool so suggestions/comments are welcome. Please use the GitHub [issue](https://github.com/Art-of-WiFi/UniFi-API-browser/issues) list or the Ubiquiti Community forums (https://community.ubnt.com/t5/UniFi-Wireless/UniFi-API-browser-tool-released/m-p/1392651) to share your ideas/questions.
1617
- please read the Security Notice below before installing this tool!
1718

1819

@@ -129,6 +130,11 @@ Alternatively you may choose to download the zip file and unzip it in your direc
129130
- after following these steps, you can open the tool in your browser (assuming you installed it in the root folder of your web server as suggested above) by going to this url: `http(s)://<server IP address>/UniFi-API-browser/`
130131

131132

133+
### UniFi OS support
134+
135+
Support for UniFi OS-based controllers (UniFi Dream Machine Pro) has been added with version 2.0.7. When adding the details for a UniFi OS device to the `config/config.php` file, please make sure not to add a port suffix or trailing slashes to the URL.
136+
137+
132138
### Extending the dropdown menu
133139

134140
Since version 2.0.0 you can extend the dropdown menu with your own options by adding them to the `config.php` file. Here's an example:

ajax/fetch_collection.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,14 @@
4646
'lan-rx_packets',
4747
'lan-tx_packets',
4848
'lan-rx_dropped',
49-
'lan-tx_dropped'
49+
'lan-tx_dropped',
50+
'wan-tx_bytes',
51+
'wan-rx_bytes',
52+
'wan2-tx_bytes',
53+
'wan2-rx_bytes',
54+
'latency_min',
55+
'latency_avg',
56+
'latency_max',
5057
];
5158

5259
/**

ajax/fetch_sites.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
*/
4949
$host = parse_url($controller['url'], PHP_URL_HOST);
5050
$port = parse_url($controller['url'], PHP_URL_PORT);
51+
$port = $port ?: 443;
5152

5253
if (!empty($host) && !empty($port)) {
5354
$fp = @fsockopen($host, $port, $errno, $errstr, 2);

ajax/show_api_debug.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
*/
4040
$host = parse_url($controller['url'], PHP_URL_HOST);
4141
$port = parse_url($controller['url'], PHP_URL_PORT);
42+
$port = $port ?: 443;
4243

4344
if (!empty($host) && !empty($port)) {
4445
$fp = @fsockopen($host, $port, $errno, $errstr, 2);

common.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* with this package in the file LICENSE.md
88
*
99
*/
10-
define('TOOL_VERSION', '2.0.6');
10+
define('TOOL_VERSION', '2.0.7');
1111

1212
/**
1313
* gather some basic information for the About modal

composer.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/custom.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ function fetchDebugDetails() {
325325
}
326326
}
327327
});
328-
}}
328+
}
329+
}
329330

330331
/**
331332
* function to fetch a collection

vendor/art-of-wifi/unifi-api-client/README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
## UniFi Controller API client class
22

3-
A PHP class which provides access to Ubiquiti's [**UniFi SDN Controller API**](https://unifi-sdn.ui.com/), versions 4.X.X and 5.X.X of the UniFi SDN Controller software are supported (version 5.11.39 has been confirmed to work). It's a standalone version of the class which is used in our API browser tool which can be found [here](https://github.com/Art-of-WiFi/UniFi-API-browser).
3+
A PHP class that provides access to Ubiquiti's [**UniFi SDN Controller**](https://unifi-sdn.ui.com/) API, versions 4.X.X and 5.X.X of the UniFi SDN Controller software are supported (version 5.12.35 has been confirmed to work) as well as UniFi OS-based controllers (version 5.12.59 has been confirmed to work). This class is used in our API browser tool which can be found [here](https://github.com/Art-of-WiFi/UniFi-API-browser).
44

5-
This class can be installed manually or using composer/[packagist](https://packagist.org/packages/art-of-wifi/unifi-api-client) for easy inclusion in your projects.
5+
The package can be installed manually or using composer/[packagist](https://packagist.org/packages/art-of-wifi/unifi-api-client) for easy inclusion in your projects.
66

77
## Requirements
88

9-
- a web server with PHP and cURL modules installed (tested on Apache 2.4 with PHP Version 5.6.1 and cURL 7.42.1 and with PHP 7.2.10 and cURL 7.58.0)
9+
- a web server with PHP and cURL modules installed (tested on Apache 2.4 with PHP Version 5.6.1 and cURL 7.42.1 and with PHP 7.2.24 and cURL 7.58.0)
1010
- network connectivity between this web server and the server and port (normally TCP port 8443) where the UniFi Controller is running
1111

12-
## Installation ##
12+
## UniFi OS Support
13+
14+
Support for UniFi OS-based controllers (UniFi Dream Machine Pro) has been added as of version 1.1.47. The class automatically detects UniFi OS devices and adjusts URLs and several functions/methods accordingly. If your own code applies strict validation of the URL that is passed to the constructor, please adapt your logic to allow URLs without a port suffix when dealing with a UniFi OS-based controller.
15+
16+
Please test all methods you plan on using thoroughly before using the API Client with UniFi OS devices in a production environment.
17+
18+
## Installation
1319

1420
You can use [Composer](#composer), [Git](#git) or simply [Download the Release](#download-the-release) to install the API client class.
1521

@@ -169,7 +175,9 @@ The class currently supports the following functions/methods to GET/POST/PUT/DEL
169175
- power_cycle_switch_port()
170176
- reconnect_sta()
171177
- rename_ap()
172-
- restart_ap()
178+
- restart_ap() (deprecated but still available as alias)
179+
- restart_device()
180+
- reboot_cloudkey()
173181
- revoke_voucher()
174182
- set_ap_radiosettings()
175183
- set_device_settings_base()
@@ -261,7 +269,7 @@ This class is based on the initial work by the following developers:
261269

262270
and the API as published by Ubiquiti:
263271

264-
- https://dl.ubnt.com/unifi/5.10.19/unifi_sh_api
272+
- https://dl.ui.com/unifi/5.12.35/unifi_sh_api
265273

266274
## Important Disclaimer
267275

vendor/art-of-wifi/unifi-api-client/examples/ap_upgrade_firmware.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* PHP API usage example
44
*
55
* contributed by: @4oo4
6-
* description: example script to check and upgrade device firmware (can be scheduled with systemd/cron)
6+
* description: example script to upgrade device firmware (can be scheduled with systemd/cron)
77
* to the most current version
88
*/
99
require_once('vendor/autoload.php');

vendor/art-of-wifi/unifi-api-client/examples/config.template.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
*/
1616
$controlleruser = ''; // the user name for access to the UniFi Controller
1717
$controllerpassword = ''; // the password for access to the UniFi Controller
18-
$controllerurl = ''; // full url to the UniFi Controller, eg. 'https://22.22.11.11:8443'
19-
$controllerversion = ''; // the version of the Controller software, eg. '4.6.6' (must be at least 4.0.0)
18+
$controllerurl = ''; // full url to the UniFi Controller, eg. 'https://22.22.11.11:8443', for UniFi OS-based
19+
// controllers a port suffix isn't required, no trailing slashes should be added
20+
$controllerversion = ''; // the version of the Controller software, e.g. '4.6.6' (must be at least 4.0.0)
2021

2122
/**
2223
* set to true (without quotes) to enable debug output to the browser and the PHP error log

0 commit comments

Comments
 (0)