[API] Invoices data is in ASC order
I hope I am posting this issue in the correct repository.
Currently, the API at https://api.linode.com/v4/account/invoices returns a list of data sorted in ascending order (oldest first).
I can see two options from here:
1- Sort the returned data with the newest first. OR 2- Add a sort query parameter with options like ASC and DESC, allowing the user to sort the data as they prefer. (https://techdocs.akamai.com/linode-api/reference/get-invoices)
Thanks
Hi @mmarif4u, thanks for reaching out! Could you try these curl requests (and add your authorization token):
curl --request GET \
--url 'https://api.linode.com/v4/account/invoices?page=1&page_size=100' \
--header 'x-filter: {"+order":"desc","+order_by":"date"}' \
--header 'accept: application/json' \
curl --request GET \
--url 'https://api.linode.com/v4/account/invoices?page=1&page_size=100' \
--header 'x-filter: {"+order":"asc","+order_by":"date"}' \
--header 'accept: application/json' \
We were able to see the data being ordered by differently - I'll look into getting the tech docs updated to reflect this!
Hi @coliu-akamai, thanks. That worked by using the x-filter in the header.
I think the API documentation needs more clarity on its content and possibilities.
Glad that worked.
I've submitted an internal ticket to update the documentation for that endpoint. Will let you know when it gets updated
Not directly related to invoices, but still related to filters.
I was checking the Events endpoint and found that there is a read object, which can also be filtered.
https://techdocs.akamai.com/linode-api/reference/get-events
I tried using the +or and +and filters, but I had no success.
https://techdocs.akamai.com/linode-api/reference/filtering-and-sorting
Can you please help me understand how the filterable options can be used with the x-filter header?
Thanks
@mmarif4u Could you let me know the requests you're trying to send?
@coliu-akamai the following is the request with the auth and x-filter headers.
https://api.linode.com/v4/account/events?page=1&page_size=100
Filter header
x-filter: {"+or":[{"read":"true"}],"+order":"desc","+order_by":"date"}
I am trying to sort the events by the read status here.
Thanks @mmarif4u! I'm not seeing a date field for Events - did you mean to sort using the created field?
{ "+order":"asc", "+order_by":"created" }
If you want all the Events where read is true, ordered by created, this should work:
{ "read": true, "+order":"desc", "+order_by":"created" }
I am seeing errors when I try to use "+or" or an explicit "+and" for this query when using the read field -- let me check with the API team to see if they have any clarifications. The guide you linked is definitely the way to go for understanding filtering/sorting though!
@mmarif4u I checked with the API team - currently read is not able to be used in compound filters, but they are looking into the issue. I'll let you know when there are updates. 😄
Is there anything else I can help you with?
@coliu-akamai Thank you so much for the heads-up on this.
Everything else seems to be fine, but I believe there is some room for improvement. For example, it’s not mentioned anywhere how to use any filterable options (read option for events in this case) in the x-filter header. I think the documentation could be improved slightly to make this clearer.
For now, this should resolve all my queries. Thanks again. :+1:
Off-topic: I have a query regarding how Linode might be able to assist with my current project. I’m building an Android app for Linode users, and I plan to make it available via the Play Store (paid) and possibly open-source through F-Droid. It’s still under development, but I wanted to ask if Linode could offer any support, such as helping to share it with your user base once it's ready, or providing some credits for testing purposes, etc. Feel free to redirect me to the appropriate channel to get in contact. Thank you!
Hi @mmarif4u, thanks for your patience. Unfortunately I'm not sure who to contact for this - I'd recommend reaching out to Akamai Compute support to see if they can help.
Going to close this issue - if you have new Cloud Manager related issues, please feel free to open a one. Thanks!