Is there a generic method to retrieve entity IDs?
You're looking for the bundle key, which can be obtained from the entity type:

$entity_type = 'node';

// Load the entity type definition and get its keys.
$keys = \Drupal::entityTypeManager()
  -&gt;getDefinition($entity_type)
  -&gt;getKeys();

$query = \Drupal::entityQuery($entity_type);

// 'bundle' is optional, if not provided it will be the same as the entity type ID, 
// but obviously you won't need to use it as a condition.
if (mb_strlen($keys['bundle'])) {
  $query-&gt;condition($keys['bundle'], $bundle);  
}

$entity_ids = $query-&gt;execute();


See EntityType::getKeys() for more information.