Get latest version of Maven repository with a REST GET

Viewed 436

I'd like to keep in a single Web page all latest releases of some APIs available on Maven.

For example: https://mvnrepository.com/artifact/org.jbpm/jbpm-kie-services

I'd like to display in the page: Kie Services: latest version 7.63.0.Final

I could parse the HTML content and find which is the latest version. On the other hand, I wonder if a simpler solution exists. Is it possible, with some query parameters, to capture this information? Thanks a lot

1 Answers

Maven Central (REST) API!

e.g.:

curl https://search.maven.org/solrsearch/select?q=g:"com.google.inject"&rows=20&wt=json

Gives us:

Search for all artifacts in the groupId "com.google.inject." For each artifact, returns details for the most recent version released.

For org.jbpm:jbpm-kie-services (latest version):

curl https://search.maven.org/solrsearch/select?q=g:"org.jbpm"+AND+a:"jbpm-kie-services"&wt=json

Returns (un-indented, un-commented):

{
  "responseHeader": {...
  },
  "response": {
    "numFound": 1,
    "start": 0,
    "docs": [{
        "id": "org.jbpm:jbpm-kie-services",
        "g": "org.jbpm",
        "a": "jbpm-kie-services",
        "latestVersion": "7.63.0.Final", // !!!
        "repositoryId": "central",...
      }]
  },...
}
Related