How to Get Catalog Rule data by rule id Magento 2?

Get Catalog Rule information by Catalog rule id using Magento 2 with Catalog Rule Repository Interface.

You need to pass Rule id as an argument to get details of Catalog rule. Original Interface class is,

We have to use the get() method from the interface to fetch details of catalog rule information.

namespace Jesadiya\CatlogRule\Model;

use Psr\Log\LoggerInterface;
use Magento\CatalogRule\Api\Data\RuleInterface;
use Magento\CatalogRule\Api\CatalogRuleRepositoryInterface;

class CatalogRuleById
     * @var CatalogRuleRepositoryInterface
    private $catalogRuleRepository;

    public function __construct(
        CatalogRuleRepositoryInterface $catalogRuleRepository,
        LoggerInterface $logger
    ) {
        $this->catalogRuleRepository = $catalogRuleRepository;
        $this->logger = $logger;

     * Gets catalog rule by id
     * @param int $ruleId
     * @return RuleInterface|null
    public function getRule(int $ruleId): ?RuleInterface
        try {
            $rule = $this->catalogRuleRepository->get($ruleId);
        } catch (NoSuchEntityException $exception) {
            $rule = null;

        return $rule;

If you want to get catalog rule details of Id 1, You need to call method $this->getRule(1);

If your system has catalog rule with id 1 is available, the result will be a display of catalog data.