how do I count results in API v4
the way the api works now, the thing returned is an ArrayObject which you can call functions on, one of those is count()

so just count the results; and then loop over them as you would if it was a normal array

  if (count($results) != 0) {
    foreach ($results as $result) {
      do things
    } 

  }