Detect request type in apiwrapper.php