Can't you just call api.main() directly here? No need to namespace it, you have an api reference in scope.