[asterisk-users] Good way to query data from asterisk realtime with Asterisk Manager API

Shitian Long longst.cn at gmail.com
Mon Sep 3 17:08:52 CDT 2012

Thanks for everyone's message, 
Finally, I figure out how to use AMI fetch data from realtime.

After log in AMI.
First step, a setVar action should be sent
(for example, in this case, I am interested in the content of realtime family = test_family, key = mykey,)

setVar action should look like 

Action: Setvar
Variable: REALTIME(test_family, key, mykey) 

After that, I should have a success response like 

Response: Success
Message: Variable Set

Afterward. I could use getVar action to fetch the result

Action: Getvar
Variable: REALTIME(test_family, key, mykey) 

Finally, query result will be in the response.

From this practice, it seems, AMI getVar and setVar action have more function than I through.

Thanks for every one's help.

On Sep 1, 2012, at 10:14 AM, Olle E. Johansson wrote:

> 31 aug 2012 kl. 16:58 skrev Shitian Long <longst.cn at gmail.com>:
>> Do you think it is a good way to use Manager API "command action" to implement this feature?
> No. The command action should be avoided since the output from the CLI commands is not
> made for parsing by applications and may change too. Sometimes we cut of informaiton to fit
> into a terminal window. If you use manager actions instead, you will always get the full data in a
> format you can parse. If you have to use the command action you have found a place where a
> manager action is missing and we developers would like to know that and fix it :-)
> For realtime, there's a dialplan function REALTIME() that you can use with the manager actions
> that change or read channel variables. That's the best way, since we lack manager realtime commands.
> One reason for not going directly to the database API is that when building 3rd party apps,
> we don't know what database you are using and can benefit from the ARA interface to databases,
> exactly like Asterisk. It's not as effecient as going directly when you can, but sometimes you just
> don't know what's behind ARA and thanks to ARA you don't have to. :-)
> /Olle
> * The new Edvina SIP Masterclass - Stockholm, Sweden Oct and Miami, FL, Dec 2012
>  http://edvina.net/training/new-sip-masterclass/--
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
> New to Asterisk? Join us for a live introductory webinar every Thurs:
>               http://www.asterisk.org/hello
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>   http://lists.digium.com/mailman/listinfo/asterisk-users

More information about the asterisk-users mailing list