Route, set meta title in controller I have a route that takes data from APIs, so I would like to set the title in the controller and not in the getTitle function because it would mean calling 2 or more times the same API
I don't think you can, not out of the box at least, but there's no reason to. Just use a static var, it will mean the API is contacted only once per request:

function getTitle() {
  static $title = '';

  if (!strlen($title)) {
    $title = $this-&gt;getTitleFromAPI();
  }

  return $title;
}