A really simple GitHub API wrapper for Node.js
npm install node-github-wrapper
var githubAPI = require('node-github-wrapper')({options});
Options:
-
appName
: Name of the application. Will be used in the request headers. -
apiRoot
: Base URL of the GitHub API. Defaults tohttps://api.github.com
. -
headers
: Headers to be sent with all requests. Defaults to:{'Accept': 'application-json', 'User-Agent': appName}
.
Please note that this library does not handle OAuth authorization. If you need to make requests that require authorization, you'll need to handle that separately, using something like node-oauth and pass the resulting access token to this library using setAccessToken()
.
Sets the access token to be used by all requests that require authorization.
Sends a GET
request to the API, with request data and a callback function.
Sends a POST
request to the API, with request data and a callback function.
Sends a PUT
request to the API, with request data and a callback function.
Sends a DELETE
request to the API, with request data and a callback function (method is called del()
because delete
is a reserved word in JavaScript).
Each requests receives as an argument an object with a set of options.
API endpoint, without the API root prefix.
{url: '/user'}
Generates https://api.github.com/user.
A list of key/value parameters to be added to the endpoint URL.
{
url: '/user',
urlParameters: {
foo: 'bar',
baz: 'qux'
}
Generates https://api.github.com/user?foo=bar&baz=qux.
The body to include in the request, in JSON format.
body: {
foo: 'bar',
baz: 'qux'
}
Overrides the default headers to be sent with the request.
headers: {
'Accept': 'application/json',
'User-Agent': 'My app name'
}
Whether to authenticate the request. Defaults to false
.
auth: true