[!TIP]

[!NOTE|label:headers]

  • -H "Accept: application/vnd.github.v3+json"
  • -H "Authorization: token YOUR_TOKEN"
  • -H "Content-Type: application/json"
  • -H "Time-Zone: Europe/Amsterdam"
  • -H "X-GitHub-Api-Version: 2022-11-28"

user

get username from token

$ curl -s -H "Authorization: token ghp_v**********************************n" https://api.github.com/user | jq -r .login
username

metadata

$ curl -sL https://api.github.com/meta | jq -r '.ssh_keys | .[]'
$ curl -sL https://api.github.com/meta | jq -r '.ssh_keys | .[]'  | sed -e 's/^/github.com /' >> ~/.ssh/know_hosts

repo

  • get repo info

    [!TIP] GET /repos/{owner}/{repo}

    # i.e.:
    $ curl -fsSL https://api.github.com/repos/marslo/ibook
    
  • get repo contributors

    [!TIP] GET /repos/{owner}/{repo}/contributors

    # i.e.:
    $ curl -fsSL https://api.github.com/repos/marslo/ibook/contributors
    

pull request

  • get pull request info

    [!TIP] GET /repos/{owner}/{repo}/pulls/{pull_number}

    # i.e.:
    $ curl -fsSL https://api.github.com/repos/marslo/ibook/pulls/1
    
  • get comments of a pull request

    [!TIP] GET /repos/{owner}/{repo}/issues/{issue_number}/comments

    # i.e.:
    $ curl -fsSL https://api.github.com/repos/marslo/ibook/issues/1/comments
    

commits / branches

  • get commits

    [!TIP] GET /repos/{owner}/{repo}/commits

    # i.e.:
    $ curl -fsSL https://api.github.com/repos/marslo/ibook/commits
    
  • post commit status

    [!TIP] POST repos/${owner}/${repo}/statuses/${sha}

    $ curl -X POST -H "Authorization: token ${GITHUB_TOKEN}" \
           -H "Accept: application/vnd.github+json" \
           https://api.github.com/repos/${OWNER}/${REPO}/statuses/${SHA} \
           -d '{
             "state": "success",
             "target_url": "https://ci.example.com/build/status/123",
             "description": "All tests passed",
             "context": "ci/build"
           }'
    
  • get branches

    [!TIP] GET /repos/{owner}/{repo}/branches

    # i.e.:
    $ curl -fsSL https://api.github.com/repos/marslo/ibook/branches
    
  • get details of a branch

    [!TIP] GET /repos/{owner}/{repo}/branches/{branch}

    # i.e.:
    $ curl -fsSL https://api.github.com/repos/marslo/ibook/branches/main
    

get actions runners

  • list workflow runs

    [!TIP] GET /repos/{owner}/{repo}/actions/runs

    # i.e.:
    $ curl -fsSL https://api.github.com/repos/marslo/ibook/actions/runs
    
  • get workflow run logs

    [!TIP] GET /repos/{owner}/{repo}/actions/runs/{run_id}/logs

    # i.e.:
    $ curl -fsSL https://api.github.com/repos/marslo/ibook/actions/runs/1234567890/logs
    
  • trigger workflow run

    [!TIP] POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches

    # i.e.:
    $ curl -X POST -H "Accept: application/vnd.github.v3+json" \
      -H "Authorization: token ghp_v**********************************n" \
      https://api.github.com/repos/marslo/ibook/actions/workflows/ci.yml/dispatches \
      -d '{"ref":"main"}'
    

version

release version

$ curl --silent 'https://api.github.com/repos/<owner>/<repo>/releases/latest' | jq -r .tag_name

# i.e.:
$ curl --silent 'https://api.github.com/repos/sharkdp/bat/releases/latest' | jq -r .tag_name

others

emoji

$ curl -fsSL -XGET https://api.github.com/emojis

zen

$ curl -fsSL -XGET https://api.github.com/zen

octocat

$ curl -fsSL -XGET https://api.github.com/octocat

rate limit

$ curl -fsSL -XGET https://api.github.com/rate_limit
Copyright © marslo 2020-2025 all right reserved,powered by GitbookLast Modified: 2025-08-25 22:09:45

results matching ""

    No results matching ""