Programmatic way to get the latest version of a crate on

A bit of background on what I want to do:

I have a bash file that maintains a list of all binary Rust crates I'd like installed.
This file contains nu, but that crate has the ugly tendency to always reinstall, not just if there is a new version like normal binary crates.

I'd like to prevent this behavior by special-casing it, specifically by asking what the latest version is for the nu crate and only installing it if the version returned by exceeds the version I have installed.

So now my question: can I programmatically, without having to crawl, ask the server what the latest listed version of a crate is?

Using bash, I'd probably call

cargo search nu --limit 1

There's also a couple API crates, including one used by Cargo, and this page mentions crawling the API. But if the API is documented somewhere, I failed to find that.

1 Like