Query for Last Record Only?

in Development
Hi,
How would I return the most recent record only?
For instance I am trying to pull the last gift card code used. What would be a good way to pull only the most recent code used please?
Hi,
How would I return the most recent record only?
For instance I am trying to pull the last gift card code used. What would be a good way to pull only the most recent code used please?
4 comments
According to the API docs, there is a query parameter for ascending/descending order, based on the orderby parameter that's supplied --> https://developers.lightspeedhq.com/retail/introduction/parameters/. Maybe try this with your API query and see how it goes!
Hi @gregarican,
That doesn't really answer the question, I am aware of the sortby parameter but his doesn't return the last record 'only'.
It's not an issue to pull the records and do what needs to be done locally.
I just wondered if it was possible to do as asked, as this would be a better solution.
Thanks.
If you look in the docs, there is also a limit parameter. Passing limit=1 means one record. Although I would test this to hell and back, given the inconsistencies and gotchas that I've run across using this API. 😂
Could work I guess. I'll give it a shot, see how it goes 👍