'How to add parameters to a GitHub API request via cURL?

I’m trying to access the GitHub API using a cURL request and having trouble adding a couple parameters.

Currently this is working:

curl \                    
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/repos/sspboyd/Presidential_Debates/commits >> output.json

I want to use the page= and per_page=100 parameters as listed here:
https://docs.github.com/en/rest/reference/repos#list-commits

I have tried using ?page=1 and /?page=1 as shown below and neither of these work:

  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/repos/sspboyd/Presidential_Debates/commits?page=1 >> output.json    
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/repos/sspboyd/Presidential_Debates/commits/?page=1 >> output.json    

Is there something I am missing here?



Solution 1:[1]

Try

-H "Accept: application/vnd.github.v3+json" \
  "https://api.github.com/repos/sspboyd/Presidential_Debates/commits?page=1" 
 >> output.json

Note the double quotes on the URL.

I was running into a similar issue with the Github api. I then figured out it was a problem with special characters in the url. In this case the ? is causing the problem.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jhnstn