Sig
Sig

Reputation: 5986

Find all of the private packages you have published to GitHub Packages

What's the API call to list all the published packages on GitHub?

I'm looking at GitHub API v4 GraphQL documentation but, since I don't know anything about GraphQL, I can't make sense of it.

At https://help.github.com/en/github/managing-packages-with-github-packages/deleting-a-package#deleting-a-version-of-a-private-package I found

To find all of the private packages you have published to GitHub Packages, along with the version IDs for the packages, you can use the registryPackagesForQuery connection. You will need a token with the read:packages and repo scopes. For more information, see "registryPackagesForQuery" in the GitHub Developer documentation.

But after that I'm basically lost.

Upvotes: 4

Views: 1504

Answers (1)

Ealrann
Ealrann

Reputation: 397

Here a cURL command to use the registryPackagesForQuery function:

curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: bearer TOKEN" \
-d '{"query":"{ user(login: \"OWNER\") { registryPackagesForQuery(first: 10, query:\"is:private\") { totalCount nodes { nameWithOwner versions(first: 10) { nodes { id version } } } } }}"}' \
https://api.github.com/graphql

Replace OWNER by your git login, and TOKEN by your personal token.

Upvotes: 3

Related Questions