LinuxCommandLibrary

gh-api

authenticated HTTP requests to GitHub REST and GraphQL APIs

TLDR

Make GET request

$ gh api [/repos/owner/repo]
copy
Make POST request
$ gh api -X POST [/repos/owner/repo/issues] -f title="[title]"
copy
With JSON body
$ gh api [/endpoint] --input [data.json]
copy
Use GraphQL
$ gh api graphql -f query='[query]'
copy
Paginate results
$ gh api [/endpoint] --paginate
copy
Output specific field
$ gh api [/repos/owner/repo] --jq '.[field]'
copy

SYNOPSIS

gh api [options] endpoint

DESCRIPTION

gh api makes authenticated HTTP requests to the GitHub API. Supports both REST and GraphQL APIs with automatic authentication.

PARAMETERS

-X, --method method

HTTP method.
-f, --field key=value
Add string field.
-F, --raw-field key=value
Add raw field.
--input file
Read body from file.
--jq query
Filter JSON output.
--paginate
Paginate results.
-H, --header header
Add HTTP header.
-t, --template template
Format output with template.

SEE ALSO

gh(1), curl(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community