library to query major clojure repos

52 Views Asked by At

Is there a clojure library, that provides functions for querying the major clojure repositories (like clojars and maven central)? I was thinking of something like this:

(query-repos "reage")
=> {reagent ("0.6.0-SNAPSHOT" "0.6.0-rc" "0.6.0-alpha2" ...)
    reagent-forms ("0.5.25" ...)}

In clj-ancient there is the function version-string!, which however seems to work only if the correct artifact name is given. (like 'reagent)

1

There are 1 best solutions below

1
On

It looks like clojars has an API. The below should be enough to get started. Just require clj-http.

(defn get-release
  [lib]
  (let [url (str "https://clojars.org/api/artifacts/" lib)
        resp (:body (clj-http.client/get url {:accept :edn}))
        info (clojure.edn/read-string resp)]
    (println "Name: " (:jar_name info) "\nLatest release: " (:latest_release info))))


user=> (get-release "reagent")
Name:  reagent 
Latest release:  0.6.0-rc

I realize now that you may be only looking for a way to do a partial match since you may not know the full repo name, so maybe this does not answer your question, but it may help others so I'll leave it. The link above has information on full listings which are in plain text and could easily be parsed and you could find partial matches easily this way.