defmain support for api queries, incl. tests