Community discussions

MikroTik App
 
User avatar
rcourtney
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 61
Joined: Wed May 22, 2013 10:55 pm

Help needed using Query in API

Mon Aug 17, 2015 8:48 pm

I will be using the API to upload users/passwords to the routers for apartment buildings.

So far the path /ip/hotspot/users/add
with numbers=n,name=userid,password=userpass (n is a number 0 to 31 reflecting bins for tennants)
adds new users.

/ip/hotspot/users/remove
with numbers=n
removes the bin entry.

I need to know how to do a query so I can retrieve the router's current information for fair use reporting, etc.

Can anyone supply me with an example?


I am basing my code off of this c++ code project:
https://github.com/silderan/QMikrotikAPI/
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: Help needed using Query in API

Mon Aug 17, 2015 9:13 pm

How would you receive it if you were "manually" reading it from a terminal?

Are you talking about the bytes-in/bytes-out info at that same menu? Just do a print request:
/ip/hotspot/user/print
If you want to read only a particular user, you can use the "from" argument, e.g.
/ip/hotspot/user/print
=from=username
Or if you want to read all users matching criteria, you can use a query with the criteria, e.g. to display all users that have uploaded more than 2GiB of data:
/ip/hotspot/user/print
?>bytes-out=2147483648
 
User avatar
rcourtney
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 61
Joined: Wed May 22, 2013 10:55 pm

Re: Help needed using Query in API

Tue Aug 18, 2015 5:00 am

Your post helped.
/ip/hotspot/user/getall getall instead of print
I need to filter either by numbers (I use bin position in place of the apartment number)

Thanks