You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-10Lines changed: 1 addition & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,3 @@
1
-
>**NOTICE**
2
-
>
3
-
>The repository has been transferred to this new GitHub organisation account, the project maintainer will remain the same and will continue to actively maintain it.
4
-
> If you have previously installed the API browser tool using `git clone`, you may consider pointing the clone to the new repository URL. You can do this with the following command from within the directory of your clone:
This tool is for browsing data that is exposed through Ubiquiti's UniFi Controller API, written in PHP, JavaScript and the [Bootstrap](http://getbootstrap.com/) CSS framework.
@@ -163,7 +154,7 @@ Showing the online device data collection using the default Bootstrap theme:
Copy file name to clipboardExpand all lines: vendor/art-of-wifi/unifi-api-client/README.md
+90-89Lines changed: 90 additions & 89 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,97 @@
1
1
## UniFi Controller API client class
2
2
3
-
A PHP class which provides access to Ubiquiti's **UniFi Controller API**, versions 4.X.X and 5.X.X of the UniFi Controller software are supported (version 5.8.24 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 which provides access to Ubiquiti's **UniFi Controller API**, versions 4.X.X and 5.X.X of the UniFi Controller software are supported (version 5.9.29 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).
4
4
5
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.
6
6
7
+
## Requirements
8
+
9
+
- a web server with PHP and cURL modules installed (tested on apache2 with PHP Version 5.6.1 and cURL 7.42.1 and with PHP 7.0.7 and cURL 7.37.0)
10
+
- network connectivity between this web server and the server and port (normally TCP port 8443) where the UniFi Controller is running
11
+
12
+
## Installation ##
13
+
14
+
You can use [Composer](#composer), [Git](#git) or simply [Download the Release](#download-the-release) to install the API client class.
15
+
16
+
### Composer
17
+
18
+
The preferred method is via [composer](https://getcomposer.org). Follow the [installation instructions](https://getcomposer.org/doc/00-intro.md) if you do not already have composer installed.
19
+
20
+
Once composer is installed, simply execute this command from the shell in your project directory:
21
+
22
+
```sh
23
+
composer require art-of-wifi/unifi-api-client
24
+
```
25
+
26
+
Or you can manually add the package to your composer.json file:
27
+
28
+
```javascript
29
+
{
30
+
"require": {
31
+
"art-of-wifi/unifi-api-client":"^1.1"
32
+
}
33
+
}
34
+
```
35
+
36
+
Finally, be sure to include the autoloader in your code:
37
+
38
+
```php
39
+
require_once('vendor/autoload.php');
40
+
```
41
+
42
+
### Git
43
+
44
+
Execute the following `git` command from the shell in your project directory:
When git is done cloning, include the file containing the class like so in your code:
51
+
52
+
```php
53
+
require_once('path/to/src/Client.php');
54
+
```
55
+
56
+
### Download the Release
57
+
58
+
If you prefer not to use composer or git, you can simply [download the package](https://github.com/Art-of-WiFi/UniFi-API-client/archive/master.zip), uncompress the zip file, then include the file containing the class in your code like so:
59
+
60
+
```php
61
+
require_once('path/to/src/Client.php');
62
+
```
63
+
64
+
## Example usage
65
+
66
+
A basic example how to use the class:
67
+
68
+
```php
69
+
/**
70
+
* load the class using the composer autoloader
71
+
*/
72
+
require_once('vendor/autoload.php');
73
+
74
+
/**
75
+
* initialize the Unifi API connection class, log in to the controller and request the alarms collection
76
+
* (this example assumes you have already assigned the correct values to the variables used)
77
+
*/
78
+
$unifi_connection = new UniFi_API\Client($controller_user, $controller_password, $controller_url, $site_id, $controller_version, true);
Please refer to the `examples/` directory for some more detailed examples which you can use as a starting point for your own PHP code.
84
+
85
+
#### IMPORTANT NOTES:
86
+
87
+
1. The last optional parameter that is passed to the constructor in the above example (`true`), enables validation of the controller's SSL certificate which is otherwise **disabled** by default. It is highly recommended to enable this feature in production environments where you have a valid SSL cert installed on the UniFi Controller, and which is associated with the FQDN of the server as used in the `controller_url` parameter. This option was added with API client version 1.1.16.
88
+
89
+
2. In the example above, `$site_id` is the 8 character short site "name" which is visible in the URL when managing the site in the UniFi Controller:
90
+
91
+
`https://<controller IP address or FQDN>:8443/manage/site/jl3z2shm/dashboard`
92
+
93
+
In this case, `jl3z2shm` is the value required for $site_id.
94
+
7
95
## Methods and functions supported
8
96
9
97
The class currently supports the following functions/methods to get/post/put/delete data through the UniFi Controller API:
@@ -139,6 +227,7 @@ The class currently supports the following functions/methods to get/post/put/del
Please refer to the source code for more details on the functions/methods and their parameters.
154
243
155
-
## Requirements
156
-
157
-
- a web server with PHP and cURL modules installed (tested on apache2 with PHP Version 5.6.1 and cURL 7.42.1 and with PHP 7.0.7 and cURL 7.37.0)
158
-
- network connectivity between this web server and the server and port (normally TCP port 8443) where the UniFi Controller is running
159
-
160
-
## Installation ##
161
-
162
-
You can use [Composer](#composer), [Git](#git) or simply [Download the Release](#download-the-release) to install the API client class.
163
-
164
-
### Composer
165
-
166
-
The preferred method is via [composer](https://getcomposer.org). Follow the [installation instructions](https://getcomposer.org/doc/00-intro.md) if you do not already have composer installed.
167
-
168
-
Once composer is installed, simply execute this command from the shell in your project directory:
169
-
170
-
```sh
171
-
composer require art-of-wifi/unifi-api-client
172
-
```
173
-
174
-
Or you can manually add the package to your composer.json file:
175
-
176
-
```javascript
177
-
{
178
-
"require": {
179
-
"art-of-wifi/unifi-api-client":"^1.1"
180
-
}
181
-
}
182
-
```
183
-
184
-
Finally, be sure to include the autoloader in your code:
185
-
186
-
```php
187
-
require_once('vendor/autoload.php');
188
-
```
189
-
190
-
### Git
191
-
192
-
Execute the following `git` command from the shell in your project directory:
When git is done cloning, include the file containing the class like so in your code:
199
-
200
-
```php
201
-
require_once('path/to/src/Client.php');
202
-
```
203
-
204
-
### Download the Release
205
-
206
-
If you prefer not to use composer or git, you can simply [download the package](https://github.com/Art-of-WiFi/UniFi-API-client/archive/master.zip), uncompress the zip file, then include the file containing the class in your code like so:
207
-
208
-
```php
209
-
require_once('path/to/src/Client.php');
210
-
```
211
-
212
-
## Example usage
213
-
214
-
A basic example how to use the class:
215
-
216
-
```php
217
-
/**
218
-
* load the class using the composer autoloader
219
-
*/
220
-
require_once('vendor/autoload.php');
221
-
222
-
/**
223
-
* initialize the Unifi API connection class, log in to the controller and request the alarms collection
224
-
* (this example assumes you have already assigned the correct values to the variables used)
225
-
*/
226
-
$unifi_connection = new UniFi_API\Client($controller_user, $controller_password, $controller_url, $site_id, $controller_version, true);
Please refer to the `examples/` directory for some more detailed examples which you can use as a starting point for your own PHP code.
232
-
233
-
#### IMPORTANT NOTES:
234
-
235
-
1. The last optional parameter that is passed to the constructor in the above example (`true`), enables validation of the controller's SSL certificate which is otherwise **disabled** by default. It is highly recommended to enable this feature in production environments where you have a valid SSL cert installed on the UniFi Controller, and which is associated with the FQDN of the server as used in the `controller_url` parameter. This option was added with API client version 1.1.16.
236
-
237
-
2. In the example above, `$site_id` is the 8 character short site "name" which is visible in the URL when managing the site in the UniFi Controller:
238
-
239
-
`https://<controller IP address or FQDN>:8443/manage/site/jl3z2shm/dashboard`
240
-
241
-
In this case, `jl3z2shm` is the value required for $site_id.
242
-
243
244
## Need help or have suggestions?
244
245
245
246
There is still work to be done to add functionality and further improve the usability of this class, so all suggestions/comments are welcome. Please use the GitHub [issue list](https://github.com/Art-of-WiFi/UniFi-API-client/issues) or the Ubiquiti Community forums (https://community.ubnt.com/t5/UniFi-Wireless/PHP-class-to-access-the-UniFi-controller-API-updates-and/td-p/1512870) to share your suggestions and questions.
Copy file name to clipboardExpand all lines: vendor/art-of-wifi/unifi-api-client/examples/README.md
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,17 @@ Then update the contents of your new config.php with your controller details and
9
9
10
10
Also make sure to update the path for the composer autoloader file (`vendor/autoload.php`) or the file containing the Class itself (`src/Client.php`) in your `require_once()` statement as required.
11
11
12
+
#### Executing scripts from the CLI
13
+
14
+
Most of the included example scripts can be run from the CLI or shell as follows after the necessary credentials and parameters have been added or updated:
15
+
16
+
17
+
```sh
18
+
$ php list_site_health.php
19
+
```
20
+
21
+
NOTE: this does require the `php-cli` module to be installed
22
+
12
23
### Contribute
13
24
14
25
If you would like to share your own example file(s), please open an issue and include your code there or else create a pull request.
0 commit comments