API Example

Hi All,

I hope this is the right place to ask this question.

I am new to the MT API and am trying to create a set of scripts to collect some data and also do management of the MT using the API rather than attempting to use telnet to emulate a console.

I have found the numerous versions of the API (PHP, Perl, Python, etc) and have read the wiki on the API. However, I am still not sure how I would do a command such as:

:put [/queue simple get [/queue simple find target-address=“10.10.10.251”] total-packets]

In the API.

Would there be a more efficient way to accomplish the same task using the API than the above console command?


I appreciate any help that you can provide as I learn quickly from seeing examples of basics and building on those examples.

you cannot use :put or other commands that start with colon. (:beep does not work also)

I feared as much.

In that case: Could anyone provide some example(s) of what I would send to the API to reproduce a similar result?

I am also having problems running the python code on the wiki, there are non-utf characters that choke the python interpreter. Are they \xFF ?

/queue/simple/find - will list all simple queue IDs

Now for each id
/queue/simple/get =.id=<any_number_you_get_from_previous_command>

You will get all values from specific queue, like example below:
!done
=ret=.id=*c,.nextid=*ffffffff,name=queue7,dst-address=0.0.0.0/0,dst-netmask=0.0.0.0,interface=all,parent=none,packet-marks=aaaa,direction=both,priority=8,queue=default-small/default-small,limit-at=0/0,max-limit=0/0,burst-limit=0/0,burst-threshold=0/0,burst-time=0s/0s,total-queue=default-small,bytes=0/0,total-bytes=0,packets=0/0,total-packets=0,dropped=0/0,total-dropped=0,overlimits=0/0,total-overlimits=0,rate=0/0,total-rate=0,packet-rate=0/0,total-packet-rate=0,queued-packets=0/0,total-queued-packets=0,queued-bytes=0/0,total-queued-bytes=0,lends=0/0,total-lends=0,borrows=0/0,total-borrows=0,pcq-queues=0/0,total-pcq-queues=0,comment=,disabled=false

Now you have to start coding. Write parser which will extract value you need.