How do I get low level data from the Flag module?
To get the total flagging count:
$count_service = \Drupal::service('flag.count');
$flag_counts = $count_service-&gt;getEntityFlagCounts($node);
$count = $flag_counts['my_flag'];

To get the current user's flagging status:
$flag_service = \Drupal::service('flag');
$my_flag = $flag_service-&gt;getFlagById('my_flag');
$user = \Drupal::currentUser();
$is_flagged= $my_flag-&gt;isFlagged($node,$user);

to toggle the flagging status:
if(!$is_flagged){
    $flag_service-&gt;flag($my_flag , $node);
}

or
if($is_flagged){
    $flag_service-&gt;unflag($my_flag , $node);
}

Best to wrap all of this into an if clause
if( $user-&gt;isAuthenticated() ){ ... }

It's probably easiest to just build my own URL / route to take care of the toggling to fit my needs.