Zend certified PHP/Magento developer

Custom shipping method available only via API

I am trying to add a custom Shipping Method that is only available via API (no storefront checkout). My starting point is the MagePsycho custom shipping module, which works fine, but as expected it shows on both checkout and API. I’m trying to find the way to hide it from the checkout (I have seen some posts and modules that make it work in the admin, but it won’t work for me).

This is the module collectRates():

        public function collectRates(RateRequest $request)
        {
                /**
                 * Make sure that Shipping method is enabled
                 */
                if (!$this->isActive()) {
                        return false;
                }

                /** @var MagentoShippingModelRateResult $result */
                $result = $this->rateResultFactory->create();

                $shippingPrice = $this->getConfigData('price');

                $method = $this->rateMethodFactory->create();

                /**
                 * Set carrier's method data
                 */
                $method->setCarrier($this->getCarrierCode());
                $method->setCarrierTitle($this->getConfigData('title'));

                /**
                 * Displayed as shipping method under Carrier
                 */
                $method->setMethod($this->getCarrierCode());
                $method->setMethodTitle($this->getConfigData('name'));

                $method->setPrice($shippingPrice);
                $method->setCost($shippingPrice);

                $result->append($method);

                return $result;
        }

So it is simply checking if it is active in the configuration, adding some more config info. How do I check there if the request is coming from the checkout or API? Or is there any other way?