How do I generate URL by term_id
What you are calling "URL aliases" are referred to by Drupal 8 as "path aliases."

The path.alias_manager service (\Drupal\Core\Path\AliasManager) allows to lookup path aliases.

$aliasManager = \Drupal::service('path.alias_manager');
// The second argument to getAliasByPath is a language code such as "en" or LanguageInterface::DEFAULT_LANGUAGE.
$alias = $aliasManager-&gt;getAliasByPath('/taxonomy/term/' . $term_id);


But what use is a path alias? The end result is probably to put it into a link render element. \Drupal\Core\Url::fromRoute should also be a valid option as that will translate into any path alias anyway. It is not exactly clear from the API documentation that it does this, but it does.

$link = [
  '#type' =&gt; 'link',
  '#title' =&gt; 'Taxonomy term ' . $term_id,
  // Passing in 'language' key as the third option is preferable here so that a language-dependent alias can be found.
  '#url' =&gt; Url::fromRoute('entity.taxonomy_term.canonical', ['taxonomy_term' =&gt; $term_id])
];