Sales by Category

brianbbrianb Posts: 2Member
edited April 2018 in Technical Documentation
I'm trying to query sales by category for a given period. Is there a way to filter on Category in a query that starts from Sales?

https://api.lightspeedapp.com/API/Account/xxxxx/Sale.json?load_relations=["SaleLines.Item"]&completeTime=><,2017-04-01T00:00:00-0400,2017-04-23T00:00:00-0400&SaleLines.Item.categoryID=IN,[1,2,3,4]

returns results, but doesn't filter to the selected categories.


https://api.lightspeedapp.com/API/Account/xxxxx/Sale.json?load_relations=["SaleLines.Item"]&completeTime=><,2017-04-01T00:00:00-0400,2017-04-23T00:00:00-0400&categoryID=IN,[1,2,3,4]

does not return results. The request times out.

I'm trying to avoid reading every sale line in the date range, as that transfers a lot of data I don't need.

Thanks

3 comments

  • jamesratcliffejamesratcliffe Posts: 160Administrator, Lightspeed Staff moderator
    @brianb No. You can only search in first level relations, so you could query on a field in the SaleLine, but not a field on the Items in each SaleLine.

    You'll have to get all the sales for the date range, then filter down to the category sales on your end.
    James Ratcliffe
    API Integrations Specialist
    Lightspeed HQ
  • brianbbrianb Posts: 2Member
    Got it. Thanks James
  • jamesratcliffejamesratcliffe Posts: 160Administrator, Lightspeed Staff moderator
    You're welcome!
    James Ratcliffe
    API Integrations Specialist
    Lightspeed HQ
Sign In or Register to comment.