Efficient way to get all commits across all branches from GitHub API?

Hello,

I’ve been studying the GitHub REST API documentation about getting commits in a repository, and I can construct a query like to following:

https://api.github.com/repos/octocat/Hello-World/commits?per_page=5&page=1&since=2010-01-01T00:00:00Z

The query response gives me information on three commits in octocat/Hello-World.

The problem is when I visit this repository’s commit page (Commits · octocat/Hello-World · GitHub), I discovered that there are more commits in its other branches. My query above only gave me commits on the master/default branch and no commits from any other branch (in this case test and octocat-patch-1).

Is there an efficient way to form my API query so that I receive information on all commits across all branches?

As part of my investigation, I also tried using the v4 GraphQL API. So far I can only construct queries that retrieve commits belonging to a single branch, but not across all branches. It looks like this (which asks for commits from the test branch):

{
  repository(owner: "octocat", name: "Hello-World") {
    refs(query: "test", refPrefix: "refs/heads/", first: 1) {
      nodes {
        target {
          ... on Commit {
            history(first: 100, after: "2010-01-01T00:00:00Z", since: null, until: null)
[rest of GraphQL query goes here...]

So my question above remains. What is the most efficient way to find all commits across all branches? Or do I need to use the GraphQL API query above on each branch the remove duplicate commits manually?

Thanks!!