Sort It Out: Sorting via API

Nov 29 2021

One of the features our customers have requested is the ability to sort packages when querying via the Cloudsmith API. Good news everyone - we can now offer that functionality!

What does this mean for me?

By default we will sort packages by the uploaded date descending (the most recently uploaded package first), but what if you wanted to view which package has the most downloads?

https://api.cloudsmith.io/v1/packages/cloudsmith/examples/?sort=-downloads

What about viewing which package has the least number of downloads, and also sort by format alphabetically?

https://api.cloudsmith.io/v1/packages/cloudsmith/examples/?sort=-format,-downloads

Does it get any more exciting than this?

Of course, the fun doesn't end there! The sorting functionality can be combined with the existing search feature - what if you wanted to see the oldest version of any Python package with `cli` in the name?

https://api.cloudsmith.io/v1/packages/cloudsmith/examples/?query=format:python%20AND%20 name:cli&sort=version

A list of fields that can be used to apply to sort can be found in our documentation. The chosen fields have been tested, optimized, and then optimized some more to ensure rapid response times, no matter how complex the query and sort.

What next?

As always, we would love to hear any feedback or suggestions - did you find this useful? What other fields (or resources) would you like to be able to sort on?

Keep up to date with our monthly product bulletin

By submitting this form, you agree to our privacy policy