Get a main image href from single Get A Product request



So I’ve looked through the get Products request and understand how to cross-reference a product image href from the relationships using ids etc.

However I can’t see how to get the image href from the Get A Product request (, or using the SDK, Moltin.Products.With(‘main_image’).Get(ID)).

Again, I do not need a list of products, just a single product. I’ve also created a main image relationship already.

I can’t see how to get an image href without also making a second api call to
/v2/products, which I’d obviously like to avoid, or just to the /products endpoint, and pull out the product I want based on id, but that payload is way larger than i need to just display a single product.

Maybe I’m missing something…suggestions most welcome!


Hey Chris,

I think you are looking to do the below. It will grab a product and its main image.

const MoltinGateway = require('@moltin/sdk').gateway
const Moltin = MoltinGateway({
  client_id: 'X'
const id = 'XXXX'
  .then(category => {
    // Do something

Let me know if this does what you need in one request?



Hi George,

From the documentation the ‘id’ in that call refers to the product id - which would be perfect, however I can only get this endpoint to work by using a category id. And this of course returns the category info with a list of products, but the products don’t have a main image href.

Could you please confirm that this endpoint, when passed a product id (and not a category id), returns the product info like in the document you referenced? I believe I have correctly set up the relationships in the store via the dashboard…




@chris.eaton Using the With() method will return the requested resources in an included hash at the root of the API response body. It’ll look something like this:


        "link": {
          "href": ""
        "file_name": "Screen Shot 2018-01-03 at 12.54.16.png",

Check out this thread for some ways in which you can match up your product with the corresponding main_image record.

Hope this helps!


Thanks Jonathan, that was the call I was originally making a few days ago but didn’t see the link.href.

Thanks for your help,



This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.