factory for api functions