Github packages

Querying packages using Github's GraphQL API

  • The query below returns a list of all packages and package versions pushed to github repo of Ampersand
  • The packages api is still in development, therefore you must include a HTTP Accept header to indicate you want to use this feature
  • Make sure the right access right are set for your personal access token. Inluding read repo + read/write packages
    POST https://api.github.com/graphql
headers: >
1
Content-Type: application/json
2
Authorization: bearer [put your personal access token here]
3
Accept: application/vnd.github.packages-preview+json
Copied!
body (grapql query):
1
{
2
"query": "query {
3
viewer { login }
4
repository(name: \"ampersand\", owner: \"ampersandtarski\") {
5
id
6
packages (first: 10) {
7
nodes {
8
id
9
name
10
versions (first: 100) {
11
nodes {
12
id version
13
}
14
}
15
}
16
}
17
}
18
}"
19
}
Copied!

Deleting specific packages

NOTE! Doesn't work with public packages, like we have
POST https://api.github.com/graphql
headers: >
1
Content-Type: application/json
2
Authorization: bearer [put your personal access token here]
3
Accept: application/vnd.github.package-deletes-preview+json
Copied!
body (graphql query) >
1
{ "query" : "mutation { deletePackageVersion(input:{packageVersionId:\"[package-version-id]==\"}) { success }}" }
Copied!