Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API] Invoices data is in ASC order #11029

Open
mmarif4u opened this issue Oct 1, 2024 · 9 comments
Open

[API] Invoices data is in ASC order #11029

mmarif4u opened this issue Oct 1, 2024 · 9 comments
Assignees

Comments

@mmarif4u
Copy link

mmarif4u commented Oct 1, 2024

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

@coliu-akamai
Copy link
Contributor

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!

@coliu-akamai coliu-akamai self-assigned this Oct 2, 2024
@mmarif4u
Copy link
Author

mmarif4u commented Oct 3, 2024

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.

@coliu-akamai
Copy link
Contributor

Glad that worked.

I've submitted an internal ticket to update the documentation for that endpoint. Will let you know when it gets updated

@mmarif4u
Copy link
Author

mmarif4u commented Oct 3, 2024

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

@coliu-akamai
Copy link
Contributor

@mmarif4u Could you let me know the requests you're trying to send?

@mmarif4u
Copy link
Author

mmarif4u commented Oct 4, 2024

@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.

@coliu-akamai
Copy link
Contributor

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!

@coliu-akamai
Copy link
Contributor

coliu-akamai commented Oct 7, 2024

@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?

@mmarif4u
Copy link
Author

mmarif4u commented Oct 7, 2024

@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. 👍

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants