1

Star a topic can be done on the website. But how to do the same operation via GitHub API v3 or v4? I read through the reference but got no clues.

Hao Yue
  • 21
  • 3

1 Answers1

0

For the v3 REST API it's documented at Star a repository for the authenticated user

The curl example is:

curl \
  -X PUT \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/user/starred/octocat/hello-world

But this doesn't show how to insert your token, so you actually need something more like:

curl \
  -X PUT \
  -H "Authorization: token $GITHUB_API_TOKEN" \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/user/starred/octocat/hello-world

Where GITHUB_API_TOKEN has been previously set like:

GITHUB_API_TOKEN="ghp_16C7e42F292c6912E7710c838347Ae178B4a"

Per comments to this earlier question how to star a repo with github api make sure that the token used has the correct permissions to do the starring, which means having the repo scope (or at least repo_public) enabled.

I'd also love to know how to do this with the v4 GraphQl API.

Chris Swan
  • 351
  • 1
  • 3
  • 8