How to Get all products assigned to category by category id Magento 2.

You can retrieve all the products assigned to a specific category by category id in Magento 2.

Used interface:
Magento\Catalog\Api\CategoryLinkManagementInterface

Get Method from the interface to fetch a list of all the products, public function getAssignedProducts($categoryId);

Get all the assigned product to a specific category by iterate over a loop from the above method,

Output:
Magento\Catalog\Api\Data\CategoryProductLinkInterface[]

The output will be Product SKU, Product Position, category id.