Let's say that we have the Github package registry repository https://maven.pkg.github.com/someOrganization . How can I cat the list of all packages in this repo into a txt file ?
Asked
Active
Viewed 2,081 times
1 Answers
2
This can be done using Preview API for GitHub Packages. You can query it in GraphQL using:
query($login: String!) {
organization(login:$login) {
registryPackages(first:10, packageType:MAVEN) {
nodes {
name
}
}
}
}
This will output something like:
{
"data": {
"organization": {
"registryPackages": {
"nodes": [
{
"name": "package1"
},
{
"name": "package2"
}
]
}
}
}
}
At the time of writing this requires both:
- Valid Token with
org:read
andpackages:read
Accept
header for preview API:application/vnd.github.packages-preview+json
Now because you want to do this over the command line, you could curl
ing it. There's already a good answer on how to use curl
to access GitHub's GraphQL API: https://stackoverflow.com/a/42021388/1174076
Hope this helps.

bitoiu
- 6,893
- 5
- 38
- 60
-
1Great answer! Thank you – user12984928 Jan 24 '20 at 15:05