Using the garnix APIshare

garnix offers an API for programmatic access.

Create an access tokenshare

  1. Log into your garnix account
  2. Navigate to the account page
  3. Generate an access token with the API scope

Create a JWTshare

The garnix API uses short-lived JWTs for actual API requests.

Create one using basic auth:

curl -XPOST --basic --user "YOUR_GITHUB_USERNAME:YOUR_ACCESS_TOKEN" https://api.garnix.io/auth/jwt

Make API requestsshare

Use the JWT as a bearer token in the Authorization header:

curl -H "Authorization: Bearer YOUR_JWT" https://api.garnix.io/whoami

Example: Retrieving Build Status and Logsshare

JWT="YOUR_JWT"

# This is an example commit from a public repo.
# With a valid JWT this should work for all
# public repos and for private repos that you
# have access to.
COMMIT="fbd9865a68c8f7f4bd9d4e136f27be04098fe1ee"

# Select the first build of the commit
BUILD_ID=$(curl -sH "Authorization: Bearer $JWT" https://api.garnix.io/commits/$COMMIT | jq -r '.builds.[0] | .id')

echo "Logs for build $BUILD_ID:"
curl -sH "Authorization: Bearer $JWT" https://api.garnix.io/build/$BUILD_ID/logs/raw

echo "Status for build $BUILD_ID:"
curl -sH "Authorization: Bearer $JWT" https://api.garnix.io/build/$BUILD_ID | jq -r .status

Unfortunately we do not have full API documentation yet. If you are using the API, we would love feedback via email or on Discord/Matrix.