split up api class for easier testing and clearer code