Skip to content

Commit

Permalink
UniFi API browser 2.0.14
Browse files Browse the repository at this point in the history
- added menu options for new monthly stats functions/methods
- updated PHP API client to 1.1.62
- updated CDN links for Javascript and CSS resources
  • Loading branch information
malle-pietje committed Dec 10, 2020
1 parent 0750d2f commit d67ff45
Show file tree
Hide file tree
Showing 10 changed files with 276 additions and 122 deletions.
71 changes: 42 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ You will find examples and detailed instructions there.
Please keep the following in mind:

- the API browser tool doesn't support all available data collections/API endpoints, see the list below of those that are currently supported
- currently, versions 4.x.x, 5.x.x, and 6.0.x of the UniFi Controller software are supported (version 6.0.33 has been confirmed to work) as well as UbiOS-based controllers (version 5.12.59 has been confirmed to work)
- currently, versions 4.x.x, 5.x.x, and 6.0.x of the UniFi Controller software are supported (version 6.0.42 has been confirmed to work) as well as UbiOS-based controllers (version 5.12.59 has been confirmed to work)
- when accessing UbiOS-based controllers (e.g. UDM PRO) through this tool, please read the remarks below regarding UbiOS support
- 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.
- please read the Security Notice below before installing this tool!
Expand Down Expand Up @@ -45,6 +45,23 @@ The UniFi API browser tool offers the following features:

### Data collections/API endpoints currently implemented in the API browser

- Configuration
- list sites on this controller
- list site settings
- list admins for current site
- sysinfo
- self
- list wlan config
- list VoIP extension
- list network configuration
- list port configurations
- list port forwarding rules
- list firewall groups
- list current channels
- list DPI stats
- dynamic DNS configuration
- list country codes
- list Radius accounts (supported on controller version 5.5.19 and higher)
- Clients/users
- list online clients
- list guests
Expand All @@ -56,43 +73,38 @@ The UniFi API browser tool offers the following features:
- Devices
- list devices (access points, USG routers and USW switches)
- list wlan groups
- list AP groups (supported on controller version 6.0.X and higher)
- list rogue access points
- list_known_rogueaps
- list devices tags (supported on controller version 5.5.19 and higher)
- Stats
- all sites stats
- 5-minute site stats
- hourly site stats
- daily site stats
- monthly site stats
- 5-minute access point stats
- hourly access point stats
- daily access point stats
- all sites stats
- health metrics
- dashboard metrics
- monthly access point stats
- 5-minute gateway stats
- hourly gateway stats
- daily gateway stats
- monthly gateway stats
- 5-minute dashboard metrics
- hourly dashboard metrics
- site health metrics
- port forward stats
- DPI stats
- Hotspot
- stat vouchers
- stat payments
- list hotspot operators
- Configuration
- list sites on this controller
- list site settings
- list admins for current site
- sysinfo
- self
- list wlan config
- list VoIP extension
- list network configuration
- list port configurations
- list port forwarding rules
- list firewall groups
- list current channels
- list DPI stats
- dynamic DNS configuration
- list country codes
- list Radius accounts (supported on controller version 5.5.19 and higher)
- Messages
- list events
- list alarms
- count alarms
- list IDS/IPS events

Please note that the bundled API client supports many more API endpoints, not all make sense to add to the API browser though.

Expand Down Expand Up @@ -201,18 +213,19 @@ The PHP API client that comes bundled with this tool is based on the work by the

and the API as published by Ubiquiti:

- https://dl.ui.com/unifi/5.12.21-a25e774adb/unifi_sh_api
- https://dl.ui.com/unifi/6.0.41/unifi_sh_api

Other included libraries:

- Bootstrap 4 (version 4.3.1) https://getbootstrap.com
- Bootswatch themes (version 4.3.1) https://bootswatch.com
- Font Awesome icons (version 5.11.2) https://fontawesome.com
- jQuery (version 3.4.1) https://jquery.com
- Twig template engine (version 2.12.1) https://twig.symfony.com
- Highlight.js (version 9.15.10) https://highlightjs.org
- Bootstrap 4 (version 4.5.3) https://getbootstrap.com
- Bootswatch themes (version 4.5.3) https://bootswatch.com
- Font Awesome icons (version 5.15.1) https://fontawesome.com
- jQuery (version 3.5.1) https://jquery.com
- Twig template engine (version 1.44.1) https://twig.symfony.com
- Highlight.js (version 10.4.1) https://highlightjs.org
- Kint (version 2.2) https://kint-php.github.io/kint
- clipboard.js (2.0.4) https://clipboardjs.com
- clipboard.js (version 2.0.6) https://clipboardjs.com
- Moment.js (version 2.29.1) https://momentjs.com


### Security notice
Expand Down
25 changes: 23 additions & 2 deletions collections.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,15 @@
[
'label' => 'Stats',
'options' => [
[
'type' => 'collection', // or divider
'label' => 'all sites stats',
'method' => 'stat_sites',
'params' => []
],
[
'type' => 'divider', // or collection
],
[
'type' => 'collection', // or divider
'label' => '5 minutes site stats',
Expand All @@ -296,8 +305,8 @@
],
[
'type' => 'collection', // or divider
'label' => 'all sites stats',
'method' => 'stat_sites',
'label' => 'monthly site stats',
'method' => 'stat_monthly_site',
'params' => []
],
[
Expand All @@ -321,6 +330,12 @@
'method' => 'stat_daily_aps',
'params' => []
],
[
'type' => 'collection', // or divider
'label' => 'monthly access point stats',
'method' => 'stat_monthly_aps',
'params' => []
],
[
'type' => 'divider', // or collection
],
Expand All @@ -342,6 +357,12 @@
'method' => 'stat_daily_gateway',
'params' => []
],
[
'type' => 'collection', // or divider
'label' => 'monthly gateway stats',
'method' => 'stat_monthly_gateway',
'params' => []
],
[
'type' => 'divider', // or collection
],
Expand Down
4 changes: 2 additions & 2 deletions common.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
* with this package in the file LICENSE.md
*
*/
define('TOOL_VERSION', '2.0.13');
define('TOOL_VERSION', '2.0.14');

/**
* gather some basic information for the About modal
*/
$curl_info = curl_version();
$curl_info = curl_version();
$unknown_string = 'unknown';

/**
Expand Down
10 changes: 5 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions templates/collections_view.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
{% endblock %}

{% block page_scripts %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.10/highlight.min.js" integrity="sha256-1zu+3BnLYV9LdiY85uXMzii3bdrkelyp37e0ZyTAQh0=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha512-hDWGyh+Iy4Mr9AHOzUP2+Y0iVPn/BwxxaoSleEjH/i1o4EVTF/sh0/A1Syii8PWOae+uPr+T/KHwynoebSuAhw==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.4.1/highlight.min.js" integrity="sha512-DrpaExP2d7RJqNhXB41Q/zzzQrtb6J0zfnXD5XeVEWE8d9Hj54irCLj6dRS3eNepPja7DvKcV+9PnHC7A/g83A==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.10/languages/json.min.js" integrity="sha256-KPdGtw3AdDen/v6+9ue/V3m+9C2lpNiuirroLsHrJZM=" crossorigin="anonymous"></script>
<script type="text/javascript" class="init">
/**
Expand Down
12 changes: 6 additions & 6 deletions templates/layout/main.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
<title>UniFi API Browser Gen2</title>

<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha512-MoRNloxbStBcD8z3M/2BmnT+rg4IsMxPkXaGh2zD6LGNNFE80W3onsAhRcMAMrSoyWL9xD7Ert0men7vR8LUZg==" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.3/css/bootstrap.min.css" integrity="sha512-oc9+XSs1H243/FRN9Rw62Fn8EtxjEYWHXRvjS43YtueEewbS6ObfXcJNyohjHqVKFPoXXUxwc+q1K7Dee6vv9g==" crossorigin="anonymous">

<!-- placeholder to dynamically load the appropriate Bootswatch CSS file from CDN unless we already have a selected theme -->
<link rel="stylesheet" href="{% if session.theme not in ['', 'bootstrap'] %}https://stackpath.bootstrapcdn.com/bootswatch/4.5.2/{{session.theme}}/bootstrap.min.css{% endif %}" id="bootswatch_theme_stylesheet">
<link rel="stylesheet" href="{% if session.theme not in ['', 'bootstrap'] %}https://stackpath.bootstrapcdn.com/bootswatch/4.5.3/{{session.theme}}/bootstrap.min.css{% endif %}" id="bootswatch_theme_stylesheet">

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css" integrity="sha512-1PKOgIY59xJ8Co8+NE6FZ+LOAZKjy+KY8iq0G4B3CyeY6wYHN3yt9PW0XpSriVlkMXe40PTKnXrLnZ9+fkDaog==" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css" integrity="sha512-+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28IaLL3i96P9sdNyeRssA==" crossorigin="anonymous">

<!-- load the CSS file for Highlight.js from CDN -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.3/styles/github.min.css" integrity="sha512-FwY1WVsm4UQgrOXt6kaQ53w83cOHa8fSvjFn/BvVOCYVPmkSR39k/xnU+8hht3zW6JL1TBd4C/aVQIAV58Cg6A==" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.4.1/styles/github.min.css" integrity="sha512-7QTQ5Qsc/IL1k8UU2bkNFjpKTfwnvGuPYE6fzm6yeneWTEGiA3zspgjcTsSgln9m0cn3MgyE7EnDNkF1bB/uCw==" crossorigin="anonymous">

<!-- custom CSS file and favicon -->
<link rel="stylesheet" href="css/custom.css?{{tool_version}}">
Expand Down Expand Up @@ -111,8 +111,8 @@

<!-- load various Javascript files from CDN -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/js/bootstrap.bundle.min.js" integrity="sha512-kBFfSXuTKZcABVouRYGnUo35KKa1FBrYgwG4PAx7Z2Heroknm0ca2Fm2TosdrrI356EDHMW383S3ISrwKcVPUw==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.27.0/moment-with-locales.min.js" integrity="sha512-qSnlnyh7EcD3vTqRoSP4LYsy2yVuqqmnkM9tW4dWo6xvAoxuVXyM36qZK54fyCmHoY1iKi9FJAUZrlPqmGNXFw==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.3/js/bootstrap.bundle.min.js" integrity="sha512-iceXjjbmB2rwoX93Ka6HAHP+B76IY1z0o3h+N1PeDtRSsyeetU3/0QKJqGyPJcX63zysNehggFwMC/bi7dvMig==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment-with-locales.min.js" integrity="sha512-LGXaggshOkD/at6PFNcp2V2unf9LzFq6LE+sChH7ceMTDP0g2kn6Vxwgg7wkPP7AAtX+lmPqPdxB47A0Nz0cMQ==" crossorigin="anonymous"></script>

<!-- load our custom Javascript file -->
<script src="js/custom.js?{{tool_version}}"></script>
Expand Down
6 changes: 5 additions & 1 deletion vendor/art-of-wifi/unifi-api-client/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## UniFi Controller API client class

A PHP class that provides access to Ubiquiti's [**UniFi Network Controller**](https://unifi-network.ui.com/) API, versions 4.X.X and 5.X.X of the UniFi Network Controller software are supported (version 5.12.72 has been confirmed to work) as well as UbiOS-based controllers (version 5.12.59 has been confirmed to work). This class is used by our API browser tool which can be found [here](https://github.com/Art-of-WiFi/UniFi-API-browser).
A PHP class that provides access to Ubiquiti's [**UniFi Network Controller**](https://unifi-network.ui.com/) API, versions 4.X.X, 5.X.X and 6.0.X of the UniFi Network Controller software are supported (version 6.0.37 has been confirmed to work) as well as UbiOS-based controllers (version 5.12.59 has been confirmed to work). This class is used by our API browser tool which can be found [here](https://github.com/Art-of-WiFi/UniFi-API-browser).

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

Expand Down Expand Up @@ -249,6 +249,10 @@ The class currently supports the following functions/methods to GET/POST/PUT/DEL
- stat_status()
- stat_sysinfo()
- stat_voucher()
- stat_monthly_aps()
- stat_monthly_gateway()
- stat_monthly_site()
- stat_monthly_user()
- unauthorize_guest()
- unblock_sta()
- unset_locate_ap() (deprecated but still available as alias)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
if ($loginresults) {
$pdu_details = $unifi_connection->list_devices($pdu_mac);

/**
* change the model below from USPPDUP to UP1 when using a USP-Plug (thanks to @thesohoguy for contributing this)
*/
if (!empty($pdu_details) && property_exists($pdu_details[0], 'model') && $pdu_details[0]->model === 'USPPDUP' && property_exists($pdu_details[0], 'outlet_overrides')) {
$device_id = $pdu_details[0]->_id;
$outlet_overrides = $pdu_details[0]->outlet_overrides;
Expand Down
Loading

0 comments on commit d67ff45

Please sign in to comment.