Find user by mail, get extension

Hi,
I have to write a small application ( php, node or python) witch given an email will return this users extension. Which command do I need to launch? I need to use Ari, Ami, Agi ?

thanks in advance

AGI would be the best option for this, or if you can pull it from a database you can use func_odbc to do a database query.