2025-03-14 21:59:59 -06:00
|
|
|
# gh api
|
|
|
|
|
|
|
|
|
|
> Make authenticated HTTP requests to the GitHub API and print the response.
|
|
|
|
|
> More information: <https://cli.github.com/manual/gh_api>.
|
|
|
|
|
|
|
|
|
|
- Display the releases for the current repository in JSON format:
|
|
|
|
|
|
|
|
|
|
`gh api repos/:owner/:repo/releases`
|
|
|
|
|
|
|
|
|
|
- Create a reaction for a specific issue:
|
|
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
`gh api {{[-H|--header]}} {{Accept:application/vnd.github.squirrel-girl-preview+json}} {{[-f|--raw-field]}} '{{content=+1}}' {{repos/:owner/:repo/issues/123/reactions}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Display the result of a GraphQL query in JSON format:
|
|
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
`gh api graphql {{[-f|--field]}} {{name=':repo'}} {{[-f|--raw-field]}} '{{query}}'`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Send a request using a custom HTTP method:
|
|
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
`gh api {{[-X|--method]}} {{POST}} {{endpoint}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Include the HTTP response headers in the output:
|
|
|
|
|
|
2025-09-14 18:48:49 -06:00
|
|
|
`gh api {{[-i|--include]}} {{endpoint}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Do not print the response body:
|
|
|
|
|
|
|
|
|
|
`gh api --silent {{endpoint}}`
|
|
|
|
|
|
|
|
|
|
- Send a request to a specific GitHub Enterprise Server:
|
|
|
|
|
|
|
|
|
|
`gh api --hostname {{github.example.com}} {{endpoint}}`
|
|
|
|
|
|
|
|
|
|
- Display the subcommand help:
|
|
|
|
|
|
|
|
|
|
`gh api --help`
|