GitHub CLI Cheat Sheet/Query REST API and filter fields

Call the API directly and project specific values.

Section: Formatting and JSON Output

Query REST API and filter fields

bash
bash
gh api repos/{owner}/{repo} --jq "{default_branch,visibility,open_issues_count}"
Explanation

Call the API directly and project specific values.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Formatting and JSON Output
Filter PR JSON with jq syntax
Post-process JSON output using the built-in jq expression support.
OpenIn sheetbashsame section
Paginate API results
Fetch all pages from a paginated REST endpoint.
OpenIn sheetbashsame section
List PRs as JSON
Return pull request data as JSON fields.
OpenIn sheetbashsame section
Format PR output with Go template
Format JSON output using a Go template.
OpenIn sheetbashsame section
List issues as JSON
Return issue fields as JSON for scripting.
OpenIn sheetbashsame section
List workflow runs as JSON
Inspect Actions runs in script-friendly JSON.
OpenIn sheetbashsame section