I guess you should not care of this. Laravel does it for you.
Anyway APIs are just JSON request so you can check it in your controller with:
public function index(Request $request){
if($request->wantsJson()){
// I'm from API
}else{
// I'm from HTTP
}
}
But as I said, do not do this. APIs may need versioning so it's better having a different controller: /v1.0.5/ApiController.php.
Now you need to avoid repeating your logic and you can use Repository Pattern to accomplish this.