Reply
New Member
Posts: 20
Registered: ‎02-22-2014

Re: Unifi API browser tool: updates and discussion

the same way ubnt has implimented should be fine + a custome time entry field could be added so that we can specify last synced time for applicationbuilding usage

events.PNG
Veteran Member
Posts: 4,671
Registered: ‎06-13-2015
Kudos: 1266
Solutions: 218

Re: Unifi API browser tool: updates and discussion

I see what you mean; the UI of my tool however, does not yet have a logical "place" for such a daterange selector. One way of doing it would be to open a modal after selecting the events data collection, where you are presented some default ranges (1 week back, 1 month, 3 months, 1 year...) together with a date picker to select a custom date to start the events collection from.

 

The Controller API can handle this (although not published) but I need to figure out a way how to implement this in my tool, also within the limited time I already haveIcon Frown

Art of WiFi
Check out our UniFi API browser tool on GitHub. The PHP API client which it uses, can be found here on GitHub.
Our UniFi Device Search tool can be found here, and our Captive Portal solutions for UniFi can be found here.
New Member
Posts: 20
Registered: ‎02-22-2014

Re: Unifi API browser tool: updates and discussion

modal idea sounds good even though we will have to reselect "list event" to change the parameters again. But that works just fine.

 

Btw whats the purpose of this application that you are building according to you?  Thanks to you, we are using this to learn available api's functions and how to use them to control the contrller. but whats ur angle on this ?  

Veteran Member
Posts: 4,671
Registered: ‎06-13-2015
Kudos: 1266
Solutions: 218

Re: Unifi API browser tool: updates and discussion

[ Edited ]

s1threddy wrote:

modal idea sounds good even though we will have to reselect "list event" to change the parameters again. But that works just fine.

 

Btw whats the purpose of this application that you are building according to you?  Thanks to you, we are using this to learn available api's functions and how to use them to control the contrller. but whats ur angle on this ?  


I agree that the modal is not the most user-friendly approach. If I place the data selector somewhere in the body/panel I need to determine when to show it and when not, otherwise it will clutter the interface unnecessarily when not applicable.

 

I myself use the tool to understand the data structure exposed by the API and to quickly browse data collections. I am building/maintaining a fully custom dashboard (browse my image gallery to see some bits and pieces) for which I frequently need to look at the raw data exposed by the API. At first I did this by creating a quick page every time I needed something, but after a while that became a PITA to do... Which is when I started off to develop this tool, and once it was usable I thought I might as well share it with the community.Icon Wink

 

And the more people using the API, the more attention the API might get from the Ubnt developers...

Art of WiFi
Check out our UniFi API browser tool on GitHub. The PHP API client which it uses, can be found here on GitHub.
Our UniFi Device Search tool can be found here, and our Captive Portal solutions for UniFi can be found here.
Veteran Member
Posts: 4,671
Registered: ‎06-13-2015
Kudos: 1266
Solutions: 218

Re: Unifi API browser tool: updates and discussion

I just pushed a new version of the tool to github.

 

added the following new data collections:

  • list network configuration
  • self

and for hotspots:

  • stat vouchers
  • stat payments
  • list hotspot operators

added debug option to config.template.php file

updated README to reflect new data collections

Art of WiFi
Check out our UniFi API browser tool on GitHub. The PHP API client which it uses, can be found here on GitHub.
Our UniFi Device Search tool can be found here, and our Captive Portal solutions for UniFi can be found here.
Veteran Member
Posts: 4,671
Registered: ‎06-13-2015
Kudos: 1266
Solutions: 218

Re: Unifi API browser tool: updates and discussion

I pushed an update to the PHP API client to github today:

  • changed all double quotes to single quotes
  • eliminated unnecessary variable copies when decoding json results (speed ups as a result of this are especially significant with large data collections)

Here's what the performance now looks like when collecting 3000 events, run off the same server as the controller (this is on a lightweight AWS instance). Not badIcon Wink

apibrowser perf localv3.JPG

Art of WiFi
Check out our UniFi API browser tool on GitHub. The PHP API client which it uses, can be found here on GitHub.
Our UniFi Device Search tool can be found here, and our Captive Portal solutions for UniFi can be found here.
Member
Posts: 253
Registered: ‎07-19-2015
Kudos: 8
Solutions: 2

Re: Unifi API browser tool: updates and discussion

I get this error when I try and pull a lot of data - any idea how to fix?

 

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 81 bytes) in /xxxxxxx/browser/phpapi/class.unifi.php on line 361

Veteran Member
Posts: 4,671
Registered: ‎06-13-2015
Kudos: 1266
Solutions: 218

Re: Unifi API browser tool: updates and discussion

I am guessing the data set is too large to fit in the free space of the memory allocated to php. Increase the limit in your php.ini file if you have sufficient RAM. Here's just one of the many how to's:

http://tutorials.hostucan.net/how-to-increase-php-memory-limit/

Art of WiFi
Check out our UniFi API browser tool on GitHub. The PHP API client which it uses, can be found here on GitHub.
Our UniFi Device Search tool can be found here, and our Captive Portal solutions for UniFi can be found here.
Veteran Member
Posts: 4,671
Registered: ‎06-13-2015
Kudos: 1266
Solutions: 218

Re: Unifi API browser tool: updates and discussion

BTW, if not already, please make sure you have the latest version of today. One of the modifications to the API client results in lower memory consumption.

Art of WiFi
Check out our UniFi API browser tool on GitHub. The PHP API client which it uses, can be found here on GitHub.
Our UniFi Device Search tool can be found here, and our Captive Portal solutions for UniFi can be found here.
Member
Posts: 253
Registered: ‎07-19-2015
Kudos: 8
Solutions: 2

Re: Unifi API browser tool: updates and discussion

Yep it has started showing that error since I updated it to your recent version. It seemed to work fine before so I'm not sure if it could be anything you've changed that has cuased it?


Cheers

Veteran Member
Posts: 4,671
Registered: ‎06-13-2015
Kudos: 1266
Solutions: 218

Re: Unifi API browser tool: updates and discussion

@ryan123 and before that release you didn't have this memory issue with the same data collection? Any idea how many objects there are in that "stat_allusers" data collection? In my test environment, the largest collection is the one containing events, which is now at 3000.

Art of WiFi
Check out our UniFi API browser tool on GitHub. The PHP API client which it uses, can be found here on GitHub.
Our UniFi Device Search tool can be found here, and our Captive Portal solutions for UniFi can be found here.
Member
Posts: 253
Registered: ‎07-19-2015
Kudos: 8
Solutions: 2

Re: Unifi API browser tool: updates and discussion

@slooffmaster - before the release I remember this same error happening once but I refrehed the page and it worked around 10 more times. However, with this release I get the same error every time - there is around 15000 records 

 

Cheers

Veteran Member
Posts: 4,671
Registered: ‎06-13-2015
Kudos: 1266
Solutions: 218

Re: Unifi API browser tool: updates and discussion

thanks for the input. I will do some memory measurements tomorrow and see what can be done about this. 15000 is quite a lotIcon Wink

Art of WiFi
Check out our UniFi API browser tool on GitHub. The PHP API client which it uses, can be found here on GitHub.
Our UniFi Device Search tool can be found here, and our Captive Portal solutions for UniFi can be found here.
Veteran Member
Posts: 4,671
Registered: ‎06-13-2015
Kudos: 1266
Solutions: 218

Re: Unifi API browser tool: updates and discussion

@ryan123 I did some measurements this morning on the differences in memory consumption between the latest version of the PHP API client and the previous version. This is with a collection of 3000 events, doing the json_decode of the collected data.

old method: 10074072 bytes
new method: 8704208 bytes

 

Looking at this, I believe it is a coincidence you encountered the error with the latest version. My advice would be to increase the memory limit for PHP. How to change this depends on how you are running PHP, normally setting this in your php.ini config file should do the trick:

 

memory_limit = 128M

or at least to 64M. BTW, your current value of 32M is a bit low anyway...

 

 

Also, what PHP version are you at? Older versions of PHP (<5.4) have weaker garbage collection, resulting in faster memory exhaustion.

Art of WiFi
Check out our UniFi API browser tool on GitHub. The PHP API client which it uses, can be found here on GitHub.
Our UniFi Device Search tool can be found here, and our Captive Portal solutions for UniFi can be found here.
Member
Posts: 253
Registered: ‎07-19-2015
Kudos: 8
Solutions: 2

Re: Unifi API browser tool: updates and discussion

Great, thanks @slooffmaster - just updated to 128 and works perfectly! Man Happy

 

Veteran Member
Posts: 4,671
Registered: ‎06-13-2015
Kudos: 1266
Solutions: 218

Re: Unifi API browser tool: updates and discussion

thanks for confirming! I will release a new update today which shows the PHP memory info in the About modal. This will help me and users with troubleshootingIcon Wink

Art of WiFi
Check out our UniFi API browser tool on GitHub. The PHP API client which it uses, can be found here on GitHub.
Our UniFi Device Search tool can be found here, and our Captive Portal solutions for UniFi can be found here.
Veteran Member
Posts: 4,671
Registered: ‎06-13-2015
Kudos: 1266
Solutions: 218

Re: Unifi API browser tool: updates and discussion

took me a bit longer to push an update to github, but it's there nowIcon Cool

  • added PHP memory metrics to the "About" modal to help with troubleshooting
  • cleaned up the comments in the class.unifi.php file
Art of WiFi
Check out our UniFi API browser tool on GitHub. The PHP API client which it uses, can be found here on GitHub.
Our UniFi Device Search tool can be found here, and our Captive Portal solutions for UniFi can be found here.
Member
Posts: 253
Registered: ‎07-19-2015
Kudos: 8
Solutions: 2

Re: Unifi API browser tool: updates and discussion

Just updated and works fine Man Happy

Veteran Member
Posts: 4,671
Registered: ‎06-13-2015
Kudos: 1266
Solutions: 218

Re: Unifi API browser tool: updates and discussion

Thx!

Art of WiFi
Check out our UniFi API browser tool on GitHub. The PHP API client which it uses, can be found here on GitHub.
Our UniFi Device Search tool can be found here, and our Captive Portal solutions for UniFi can be found here.
New Member
Posts: 2
Registered: ‎01-18-2016

Re: Unifi API browser tool: updates and discussion

Thank you for the great work and the flowing updates!

 

As you're quite firm with the API, maybe you can help me with a slight offtopic question. Is there a way to change the SSID of the guest-wlan? As we need to change the password on a daily base, we'd like to change it as well. like guest20160118 today and guest20160119 tomorrow. If only the password is changed certain clients are unable to connect because the trying the old password.

 

Sorry if too offtopic

Thanks Chris

Reply