Issue about the parameters 'per_page' and 'page' in the API

When using some APIs to list the objects we want to view, such as “List repository tags”, “List commits on a pull request”, “List workflow runs for a repository”, etc., generally we can see the following two parameters are mentioned to be available to these APIs:

Name Type In Description
per_page integer query Results per page (max 100)
page integer query Page number of the results to fetch.

Accourding to my understanding, for example, I have 208 workflow runs in one of my repository, and I execute the API like as below:

https://api.github.com/repos/owner/repo/actions/runs?per_page=100&page=<page_number>
  • when set page=1, the API return 100 runs.

    https://api.github.com/repos/owner/repo/actions/runs?per_page=100&page=1
    

    result:

    {
        "total_count": 208,
        "workflow_runs": [
          --- list 100 runs ---
        ]
    }
    
  • when set page=2, the API should return another 100 runs.

    https://api.github.com/repos/owner/repo/actions/runs?per_page=100&page=2
    

    result:

    {
        "total_count": 208,
        "workflow_runs": [
          --- list another 100 runs ---
        ]
    }
    
  • when set page=3, the API should return the rest 8 runs.

    https://api.github.com/repos/owner/repo/actions/runs?per_page=100&page=3
    

    result:

    {
        "total_count": 208,
        "workflow_runs": [
          --- list the rest 8 runs ---
        ]
    }
    
  • when set page=4 (or large than 4), the API should return an empty array (length=0).

    https://api.github.com/repos/owner/repo/actions/runs?per_page=100&page=4
    

    result:

    {
        "total_count": 208,
        "workflow_runs": []
    }
    

When I execute the API on Postman, it can correctly display the runs in each page, just likes as I mentioned above.
But when I execute the API in the shell scripts (Bash), it can’t correctly display in each page. No matter what page number I set, it always returns 100 runs in each page. This looks like a bug for the API.

Hi team,

Any suggestions?

Finally, I got the solution that using the double quotes (“”) to surround the API URL.
See the shell script: https://github.com/TestWorkflowsRML/RunAPI_Bash/blob/4ee8c4de131d9ddb31f0021bcba4b6d1a90c48a3/src/list-repo-workflow-runs.yml

The while loop can break as expected now. See the result here: https://github.com/TestWorkflowsRML/RunAPI_Bash/runs/1208532662?check_suite_focus=true#step:3:16

Thanks for the help from Ivan Zuzak.

I think the examples on the docs about the API should be changed to add the double quotes to surround the API URLs. Otherwise this may mislead users, just like the problem I was facing.
Current on the docs page:

curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/repos/octocat/hello-world/actions/runs

Expected on the docs page:

curl \
  -H "Accept: application/vnd.github.v3+json" \
  "https://api.github.com/repos/octocat/hello-world/actions/runs"