# gh api

Authenticated API calls, no token juggling.

## Quick answer
```
gh api repos/cli/cli
```

## Syntax
```
gh api <endpoint> [flags]
```

## Examples

# GET a REST endpoint
gh api repos/cli/cli

# Filter the response with jq
gh api repos/cli/cli --jq ".stargazers_count"

# Follow pagination for every result
gh api --paginate users/octocat/repos

# POST with fields
gh api repos/{owner}/{repo}/issues -f title="Bug" -f body="details"

# Run a GraphQL query
gh api graphql -f query='{ viewer { login } }'

## Key flags

  -X, --method	HTTP method (default GET, or POST when fields are set).
  -f, --raw-field	Add a string parameter (key=value).
  -F, --field	Add a typed parameter (numbers, booleans, @file, placeholders).
  --paginate	Fetch every page of results automatically.
  -q, --jq	Filter the JSON response with a jq expression.
  -H, --header	Add an HTTP request header.
  --hostname	Target a GitHub Enterprise host.

Full guide: https://ghcli.com/gh-api.php
