Package search API

Does anyone know how to get packages using GithHub search API?

2 Likes

Hi, I’ve been wondering about this as well, I’ve just been playing with the graphQL API, in their explorer https://developer.github.com/v4/explorer/, in the above query I’m trying to find artifacts with a specific version, I’m not completely there, but this might interest you.

query { 
  repository(owner:"org", name:"maven-packages") {
    packages(
      last: 30, 
      packageType: MAVEN
    ) {
      edges {
        node {
          name,
          # statistics {
          #   downloadsTotalCount
          # },
          latestVersion {
            version
          },
          version(version: "5.47.0") {
            version
          }
        }
      }
    }
  }
}

Which will yield a result like that :

{
  "data": {
    "repository": {
      "packages": {
        "edges": [
          {
            "node": {
              "name": "groupId.artifactId1",
              "latestVersion": {
                "version": "5.48.0"
              },
              "version": {
                "version": "5.47.0"
              }
            }
          },

          // ...

          {
            "node": {
              "name": "groupId.artifactId2",
              "latestVersion": {
                "version": "1.0-SNAPSHOT"
              },
              "version": null
            }
          },
          {
            "node": {
              "name": "deleted_0934ac34-7dff-4e25-9651-b4152001141f",
              "latestVersion": null,
              "version": null
            }
          }
        ]
      }
    }
  }
}

However I don’t quite get yet how to remove deleted packages, or nulls.

Here’s the documentation I’m using

1 Like