Square Brackets not valid URLs?

Ok so Im trying to load_Relations which according to the API examples requires square brackets,
I noticed there is a tip referencing encoding of reserved characters, I have try the following urls and get an 'Invalid Argument' error for this url:
At the end of the day I need to grab sales data that includes:
I noticed there is a tip referencing encoding of reserved characters, I have try the following urls and get an 'Invalid Argument' error for this url:
https://api.lightspeedapp.com/API/Account/accountID/Sale.json?load_relations=%5B"SaleLines","SaleLines.item"%5D&shopID=3and the same for this url:
https://api.lightspeedapp.com/API/Account/accountID/Sale.json?load_relations=["SaleLines","SaleLines.item"]&shopID=3
At the end of the day I need to grab sales data that includes:
I would like to have this data updated every 15 minutes and merging multiple data calls seems like a nightmare as opposed to making a single call with the correct fields?
Employee(s)
Hours worked by D/W/M
Average Sales D/W/M
Units Per Sale D/W/M
Total Sales D/W/M
Sales
Store Total By D/W/MTD
Average Sales D/W/MTD
Units Per Sale D/W/MTD
Sales By Hour MTD/YTD
Sales By Day MTD/YTD
Store Margin D/M/YTD
Product
Top 10 Products MTD/YTD
Advice and suggestions much appreciated
Post edited by LiquidLuke on
Much thanks for everyone's help!
8 comments
https://api.merchantos.com/API/Account/{AccountID}/Sale.json?archived=false&shopID=3&load_relations=["SaleLines","SaleLines.Discount","SaleLines.Note","SaleLines.Item","SalePayments","SalePayments.PaymentType","SalePayments.SaleAccounts","Customer","Customer.Contact","Discount"]&offset=0&limit=100
If you only needed daily reporting what I would suggest is what I instituted here. After-hours I pull all the product, customer, vendor, sales, etc. data via the LS Retail API. Push it all into local SQL Server DB tables. Then I can create any slice-and-dice type of report to render whatever my endusers request. It's a lot easier then, so the response time is super-quick, any new angles in terms of table joins for a different view can be taken into account, and the stingy LS Retail API throttling is transparent to the endusers.
Since you are looking for a more real-time view of what's going on, you will likely have to make a couple of interrelated API queries. Pull the sales, store the associated employee ID's in a variable, pull their full names, pull their hours, etc. Then the other branch would be off the initial sales pull --- storing the associated product ID's in a variable, in order to pull the product identifiers, etc.
The end game will be a very effective dashboard for sure. If it were me I'd still store all the MTD and YTD data in some local middleman DB. Then you would just have to pull the current daily sales in real-time from the API...
I'm actually having trouble with the query portion as it's just returning all of the data and not the data > last entry, is there something about the syntax that iI have wrong maybe?
Adrian Samuel
Software Developer
Lightspeed HQ
is this one ok?
load_relations[] or visa versa?
Ive done my best to be as DRY as possible for now and have most common function call populated in a custom menu in google sheets and I would like to make this a plugin available in the google marketplace at some point. if I ever do I ill let you know
@LiquidLuke haha it always happens!!
Great work! I actually had an identical idea myself haha, probably going to schedule sometime for myself to hack it out
What back-end language/framework are you using?
Adrian Samuel
Software Developer
Lightspeed HQ
I'm currently segmenting my code as much as possible to allow for additional endpoints without rewriting all the code with the different endpoints explicitly defined, but the relations make it tough. I'm basically trying to automate invoicing and order managing as many of our suppliers require a csv with the details be uploaded to their site for processing. Also, I have the sales and various stats being displayed on a user-specific dashboard. and all of this code centralized from a single Spreadsheet script lol.
Admittedly it's getting a little frazzled hence my now focus on cleaning and modulizing my code, Id love any feedback if you wanna have a look. you can check out my code on Github.com/marshallsbest /lightspeed-api
And I can't seem to push the lates down to Github at the moment But I will as sooin as Github is back up.