I am not sure what it means when it tells me to use:
GET /repos/:owner/:repo/commits/:sha
How can I use that API call to retrieve the information I am looking fo
GET /repos/:owner/:repo/commits/:sha
GET
is the HTTP method to use in order to invoke this API endpoint.
:owner
is the name of the user or organization (eg. octocat
is the name of a user).
:repo
is the name of a repository owned by the chosen user or organization (eg. the octocat
user shares the Spoon-Knife repository)
:sha
is the 40 bytes long unique identifier of a Git Object
You have to prepend you call with the root endpoint -> https://api.github.com
.
Considering this, in order to show
One would issue a GET Http call to the following url
https://api.github.com/repos/octocat/Spoon-Knife/commits/bb4cc8d3b2e14b3af5df699876dd4ff3acd00b7f
For instance, using the following curl command...
$ curl https://api.github.com/repos/octocat/Spoon-Knife/commits/bb4cc8d3b2e14b3
af5df699876dd4ff3acd00b7f
...will return the following Json payload
{
"sha": "bb4cc8d3b2e14b3af5df699876dd4ff3acd00b7f",
"commit": {
"author": {
"name": "The Octocat",
"email": "octocat@nowhere.com",
"date": "2014-02-04T22:38:36Z"
},
"committer": {
"name": "The Octocat",
"email": "octocat@nowhere.com",
"date": "2014-02-12T23:18:55Z"
},
"message": "Create styles.css and updated README",
...[snipped for brevity]...
"patch": "@@ -0,0 +1,17 @@\n+* {\n+ margin:0px;\n+ padding:0px;\n+}\n+\n+#octocat {\n+ display: block;\n+ width:384px;\n+ margin: 50px auto;\n+}\n+\n+p {\n+ display: block;\n+ width: 400px;\n+ margin: 50px auto;\n+ font: 30px Monaco,\"Courier New\",\"DejaVu Sans Mono\",\"Bitstream Vera Sans Mono\",monospace;\n+}"
}
]
}
As rightfully pointed at by @matsjoyce, numerous libraries abstract this low level operations and expose a more user friendly interface. Most of them are listed at https://developer.github.com/libraries/