GH-API(1) GitHub CLI manual GH-API(1) (NAME) gh-api - (API) (SYNOPSIS) gh api [flags] (DESCRIPTION) HTTP ( ) (GitHub API) . endpoint (GitHub API v3) graphql (GitHub API v4). {owner} {repo} {branch} endpoint GH_REPO . PowerShell {...} . -p/--preview (previews) (feature-flagged) . Accept application/vnd.github.-preview+json --preview . corsair scarlet witch -p corsair,scarlet-witch --preview corsair --preview scarlet-witch . HTTP GET POST . --method . -f/--raw-field key=value (payload) . -F/--field . POST . (query string) GET --method GET . -F/--field : o (literal) true false null JSON o {owner} {repo} {branch} o @ . (stdin) - . GraphQL query operationName GraphQL . key[subkey]=value . key[]=value1 key[]=value2 . key[] . JSON --input . - . (query string) . --paginate . GraphQL $endCursor: String pageInfo{ hasNextPage, endCursor } . JSON . JSON JSON --slurp . (OPTIONS) --allow-escape-sequences (escape sequences) --cache "3600s" "60m" "1h" -F, --field key=value ( stdin "@" "@-" ) -H, --header HTTP key:value --hostname ( "github.com") -i, --include HTTP --input HTTP ( "-" ) -q, --jq jq -X, --method ( "GET") HTTP --paginate HTTP -p, --preview ( '-preview' ) -f, --raw-field key=value --silent --slurp "--paginate" JSON -t, --template JSON Go "gh help formatting" --verbose HTTP (EXIT CODES) 0: 1: 2: 4: : . . (EXAMPLES) # (releases) $ gh api repos/{owner}/{repo}/releases # (issue) $ gh api repos/{owner}/{repo}/issues/123/comments -f body='Hi from CLI' # $ gh api gists -F 'files[myfile.txt][content]=@myfile.txt' # GET $ gh api -X GET search/issues -f q='repo:cli/cli is:open remote' # JSON $ gh api repos/{owner}/{repo}/rulesets --input file.json # HTTP $ gh api -H 'Accept: application/vnd.github.v3.raw+json' ... # $ gh api --preview baptiste,nebula ... # $ gh api repos/{owner}/{repo}/issues --jq '.[].title' # $ gh api repos/{owner}/{repo}/issues --template \ '{{range .}}{{.title}} ({{.labels | pluck "name" | join ", " | color "yellow"}}){{"\n"}}{{end}}' # "environment" $ gh api -X PATCH /orgs/{org}/properties/schema \ -F 'properties[][property_name]=environment' \ -F 'properties[][default_value]=production' \ -F 'properties[][allowed_values][]=staging' \ -F 'properties[][allowed_values][]=production' # GraphQL $ gh api graphql -F owner='{owner}' -F name='{repo}' -f query=' query($name: String!, $owner: String!) { repository(owner: $owner, name: $name) { releases(last: 3) { nodes { tagName } } } } ' # $ gh api graphql --paginate -f query=' query($endCursor: String) { viewer { repositories(first: 100, after: $endCursor) { nodes { nameWithOwner } pageInfo { hasNextPage endCursor } } } } ' # (forks) $ gh api graphql --paginate --slurp -f query=' query($endCursor: String) { viewer { repositories(first: 100, after: $endCursor) { nodes { isFork } pageInfo { hasNextPage endCursor } } } } ' | jq 'def count(e): reduce e as $_ (0;.+1); [.[].data.viewer.repositories.nodes[]] as $r | count(select($r[].isFork))/count($r[])' (SEE ALSO) gh(1) Sep 2026 GH-API(1)