How to Reindex prices by product ids programmatically Magento 2?

You can reindex only prices for the products in Magento 2 store by their ids.

Indexer id used for the prices is catalog_product_price. We need to reindex only prices programmatically to reflect the price changes on the backend. you can do it using CLI command also,
php bin/magento indexer:reindex catalog_product_price

Using code, check the demo,

namespace Jesadiya\PriceIndexer\Model;

use Magento\Catalog\Model\Indexer\Product\Price\Processor as PriceIndexerProcessor;

class PriceIndexer
     * @var PriceIndexerProcessor
    private $priceIndexProcessor;

    public function __construct(
        PriceIndexerProcessor $priceIndexProcessor
    ) {
        $this->priceIndexProcessor = $priceIndexProcessor;

     * reindex price
     * @param array $productIds
     * @return void
    public function reindexPrice(array $productIds)
        return $this->priceIndexProcessor->reindexList($productIds);

Call method with required ids,

$productIds = [1,2,3];