Easier way to get category ID for each product

shopjbshopjb Posts: 9Member
Hi,
I am fetching multiple products and I also need the category ID that each product belongs to. Now if I make one API call to get 100 products, I need to make an additonal 100 API calls to get each products' category via CategoriesProducts. This way the API limit is reached quite fast. Is there an easier way to get the product data including the category IDs?

6 comments

  • LeahLeah Posts: 80Moderator, Lightspeed Staff moderator
    Hi @shopjb,

    It sounds like you need the Catalog endpoint. You can return all the product information including the category IDs in one call. 
    API Support
    Lightspeed HQ
  • shopjbshopjb Posts: 9Member
    edited October 2018
    Leah said:
    Hi @shopjb,

    It sounds like you need the Catalog endpoint. You can return all the product information including the category IDs in one call. 
    That sounds good indeed! But it seems with Catalog a couple of Variant attributes are missing:
    - image
    - sizeUnit
    - weightUnit

    What's up with that?
  • shopjbshopjb Posts: 9Member
    @Leah
    Ok, I noticed that the size attributes are always in cm and the weight is always in gram. Is this the same for every Lightspeed shop or only for those in Europe? Do shops from USA always output those things in inch and ounces?

    But I am still missing the images. How do I know which product image is assigned to which variant?
  • LeahLeah Posts: 80Moderator, Lightspeed Staff moderator
    Yes, the weights and dimensions are always in grams and centimeters by default. Users are able to store their values in other units, which are then converted. The properties 'sizeX', 'sizeY',and 'sizeZ' as well as 'weight' are available at the Catalog endpoint and are in these default units.

    The properties that allow you to choose your units are 'sizeXValue', 'sizeYValue', 'sizeZValue' along with 'sizeUnit', and 'weightValue' along with 'weightUnit.'

    These properties are accessible at the Variant endpoint but are excluded from the Catalog endpoint.

    Similarly, you can access the variant 'image' property at the Variant endpoint but not at the Catalog endpoint.

    API Support
    Lightspeed HQ
  • shopjbshopjb Posts: 9Member
    So I need to make another request for every variant just because of the image :(
    Would be way easier if it would be included in the Catalog endpoint?
  • LeahLeah Posts: 80Moderator, Lightspeed Staff moderator
    While the catalog endpoint provides a wealth of product data, not all product fields can be included because the response would be too large. Another option for reducing calls could be to store data on your end and then update as necessary via webhooks
    API Support
    Lightspeed HQ
Sign In or Register to comment.