GraphQL API Get preview link for unpublished products

Highlighted
New Member
2 0 0

Hi,
I need to get the "preview URL" for an unpublished product from the  API (GraphQL or REST).
There is still a preview button on the product details page in the administration when a product is not published 
( its URL is something like {hashed-domain}.shopifypreview.com/products_preview?preview_key={hash_key})
but I couldn't find something for this in APIs documentation.

Is there a way I can get this "unpublished product preview link" from the API?
Thanks in advance.

0 Likes
Highlighted
New Member
1 0 0

Found it in the GraphQL API:

 

query {
  product(
    id: "gid://.."
  ) {
    onlineStorePreviewUrl
  }
}

which returns

 

 

{
"data": {
  "product": {
    "onlineStorePreviewUrl": "https://{hash}.shopifypreview.com/products_preview?preview_key={hash}"
    }
},
}

 

 

0 Likes