Loading all products via API?

Study13Study13 Member Posts: 5

Hello, I would like to analyze all products of a shop. If I request products via the API, the list of products is limited by 250 products. Therefore I need 20 requests for all products (about 4800 products). This results in a long loading time of my webpage. Can you provide an interface for the API to get all products which are currently listed in the shop with one single request? I am using PHP by the way. A direct access to the database would be obviously the best, but I guess that you might not provide it because of security issues.

5 comments

  • Adrian SamuelAdrian Samuel Moderator, Lightspeed Staff Posts: 556 moderator

    Hey @Study13.

    You are correct, the API servers as an abstraction layer for the core application whilst simultaneously providing a consistent and stable and secure tunnel for you to retrieve and update data.

    If you're using the API to update and serve your website, you should build a database to persist the data and use that to serve your site. To make the whole process efficient you should only update the items that have changes in your eCommerce so you only need to make those changes to your database.


    You can configure web-hooks for your eCommerce store to send events to your application to achieve this.

    More information about web-hooks can be found here:

    https://developers.lightspeedhq.com/ecom/tutorials/webhooks/

    Adrian Samuel

    API Integrations Consultant - Strategic Solutions

    Lightspeed HQ

  • Study13Study13 Member Posts: 5

    Hey Adrian,

    the idea is good. I still have one problem. How can I detect which product is deleted? It seems that there is no information in the json response in comparison to inserting or updating a product. Do you have any idea?

  • Adrian SamuelAdrian Samuel Moderator, Lightspeed Staff Posts: 556 moderator

    Hey @Study13,

    Great question!

    So when a product is deleted, you'll get a web-hook fired as per the docs

    You are right in that you don't get a JSON response but you do get headers with the relevant meta information.

    x-product-id will contain the productID of the item in question which you would have mapped to your database

    x-event will contain: products/deleted

    I hope this helps!

    Adrian Samuel

    API Integrations Consultant - Strategic Solutions

    Lightspeed HQ

  • Adrian SamuelAdrian Samuel Moderator, Lightspeed Staff Posts: 556 moderator

    @Study13, haha it's probably the tool I used. It probably lower-cases everything :)

    Adrian Samuel

    API Integrations Consultant - Strategic Solutions

    Lightspeed HQ

Sign In or Register to comment.