Need to manage PRs and issues programmatically via GitHub API when `gh` CLI is not authenticated or unavailable.
Need to manage PRs and issues programmatically via GitHub API when gh CLI is not authenticated or unavailable.
GitHub REST API v3 allows full CRUD operations on PRs, issues, and comments using personal access tokens (PAT). The API endpoints follow predictable patterns:
GET/POST/PATCH /repos/{owner}/{repo}/issues/{number}GET/POST/PATCH /repos/{owner}/{repo}/pulls/{number}GET/POST /repos/{owner}/{repo}/issues/{number}/commentsPUT /repos/{owner}/{repo}/pulls/{number}/merge# Extract token from git credentials
TOKEN=$(cat ~/.git-credentials | grep -i "github.com" | head -1 | sed 's/.*:\/\/[^:]*:\([^@]*\)@.*/\1/')
# Or set directly
TOKEN="ghp_xxxxxxxxxxxx"Expected Output:
On branch main
OKjq for JSON parsing: curl ... | jq '.html_url'-d @/tmp/issue.json