Using "where" and "find" in MikroTik API

I am trying to use the MikroTik API to get the same results as the command line command:
/ip hotspot active print where user=bokad

I have tried:
--------------1--------------------------
$API->write(‘/ip/hotspot/active/print’,false);
$API->write(‘=where=’,false);
$API->write(‘=user=bokad’,true);

--------------2--------------------------
$API->write(‘/ip/hotspot/active/print’,false);
$API->write(‘=where’,false);
$API->write(‘=user=bokad’,true);

--------------3--------------------------
$API->write(‘/ip/hotspot/active/print’,false);
$API->write(‘=where=user=bokad’,true);

#1 and #2 just result in “=message=argument error”
#3 returns a list of all the users, not what I want.

Is there a way to use the where and find commands in the API?

I am using the PHP API found at:
http://wiki.mikrotik.com/wiki/API_PHP_class

There’s no “find” command in API.
You have to print/getall everything and search for the right .id yourself (in the results)…

Bummer. It’s kinda inefficient to transfer an entire list of 1600 logged in users across a slow connection when you just need information on one of them.
Do you know of any plans to implement find or where?
Is there a documentation source for the API with more information than the Wiki?

Thanks.

I don’t know of any more information, too. Perhaps writing to support@mikrotik.com can give you more answers…

Anymore information on this?
I found the only way to remove a user is to use the .id field.
This does seem quite silly since you know the user name and the IP address, but not the ID, so why make it so you can only remove a user on a field that is not known to you unless you do a print and filter the results? That just adds overhead to the process, and not really all that logical…to me anyway.

Would love to hear any more about this.

Jeremy

since 3.21 one can use queries in ‘print’ API command - it’s analogue of ‘fint’ in CLI

exactly, queries showed up in 3.21 (3.22) and will stay there for long time, if you are using find, or plan using find, use queries and .proplist to get values you need, to avoid additional parsing of output.

look for more info on wiki API article:
http://wiki.mikrotik.com/wiki/API#Command_description

also, there is news about upcoming changes on how to get OIDs.

good day
is it possible make this API query /queue simple print where name~“ANDY” ?

yes

/queue/simple/print
?name=ANDY

just to add - you can use queue name directly as value for .id argument to alter/monitor the queue.

hi
i tryed that but it doesnt show for example “ANDY LEE”

/queue/simple/print
?name=ANDY -------> /queue simple print where name=ANDY


/queue/simple/print

?(?)(?) ------> /queue simple print where name~“ANDY” this works for “ANDY LEE”

unfortunately, you cannot use regular expression matching in API
if you need to match by name prefix and don’t want to receive all names to process them on client side, ugly workaround coud be like this:

/some/command/print
?>name=begi[u]n[/u]
?<name=begi[u]o[/u]
?#&