Magento 2 API – How to Get a Product URL

apimagento2producturl

In Magento 2, it is possible to get a product's URL using the information returned via the API/Repositories?

That is, when grabbing a list of products from the API, the url_key will be returned as part of the custom_attribute array.

  8 => 
    array (size=2)
      'attribute_code' => string 'url_key' (length=7)
      'value' => string 'joust-duffle-bag' (length=16)

However, the actual product URL in the system will not be returned.

Is there a way, using only the API, to get a product's actual URL?

Or am I mistaken, and calls to the ProductRepository API method should include the URL. If so, what should those calls look like?

Or does this question not make sense due to the way Magento 2 handles product URLs? If so, what's "dumb" about this question?

I realize it's possible, using the provided PHP objects, to use a Magento\Catalog\Model\Product\Url object with an instantiated Magento\Catalog\Model\Product object. What I'm looking for is an "API only" way to return a product's URL.

Best Answer

After extensive research and two months of being open, it seems the answer to this question is No. The Magento 2 API can't be used to directly fetch a product URL.

Related Topic