Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 126 lines (89 sloc) 3.569 kB
4981dca @mikedeboer move from https://github.com/c9/node-github3 to https://github.com/aj…
mikedeboer authored
1 # JavaScript GitHub API for Node.JS
6355ebe @fjakobs add readme
fjakobs authored
2
3f56822 @mikedeboer removed asyncjs as dev dependency and updated README unit testing ins…
mikedeboer authored
3 A Node.JS module, which provides an object oriented wrapper for the GitHub v3 API.
6355ebe @fjakobs add readme
fjakobs authored
4
e097c60 @fjakobs add install notes to the readme
fjakobs authored
5 ## Installation
6
4981dca @mikedeboer move from https://github.com/c9/node-github3 to https://github.com/aj…
mikedeboer authored
7 Install with the Node.JS package manager [npm](http://npmjs.org/):
aee368b @alexwhitman Update sys to util and remove where not used
alexwhitman authored
8
e7b1cc4 @mikedeboer updated docs to reflect new location of the repo.
mikedeboer authored
9 $ npm install github
e097c60 @fjakobs add install notes to the readme
fjakobs authored
10
11 or
12
13 Install via git clone:
aee368b @alexwhitman Update sys to util and remove where not used
alexwhitman authored
14
e7b1cc4 @mikedeboer updated docs to reflect new location of the repo.
mikedeboer authored
15 $ git clone git://github.com/ajaxorg/node-github.git
16 $ cd node-github
34cab70 @fjakobs update readme
fjakobs authored
17 $ npm install
e097c60 @fjakobs add install notes to the readme
fjakobs authored
18
4981dca @mikedeboer move from https://github.com/c9/node-github3 to https://github.com/aj…
mikedeboer authored
19 ## Documentation
20
e7b1cc4 @mikedeboer updated docs to reflect new location of the repo.
mikedeboer authored
21 You can find the docs for the API of this client at [http://ajaxorg.github.com/node-github/](http://ajaxorg.github.com/node-github/)
4981dca @mikedeboer move from https://github.com/c9/node-github3 to https://github.com/aj…
mikedeboer authored
22
3f56822 @mikedeboer removed asyncjs as dev dependency and updated README unit testing ins…
mikedeboer authored
23 Additionally, the [official Github documentation](http://developer.github.com/)
4981dca @mikedeboer move from https://github.com/c9/node-github3 to https://github.com/aj…
mikedeboer authored
24 is a very useful resource.
25
6355ebe @fjakobs add readme
fjakobs authored
26 ## Example
27
4981dca @mikedeboer move from https://github.com/c9/node-github3 to https://github.com/aj…
mikedeboer authored
28 Print all followers of the user "mikedeboer" to the console.
6355ebe @fjakobs add readme
fjakobs authored
29
e7b1cc4 @mikedeboer updated docs to reflect new location of the repo.
mikedeboer authored
30 var GitHubApi = require("github");
6355ebe @fjakobs add readme
fjakobs authored
31
4981dca @mikedeboer move from https://github.com/c9/node-github3 to https://github.com/aj…
mikedeboer authored
32 var github = new GitHubApi({
d70dfbb @p Timeout support
p authored
33 // required
34 version: "3.0.0",
35 // optional
36 timeout: 5000
4981dca @mikedeboer move from https://github.com/c9/node-github3 to https://github.com/aj…
mikedeboer authored
37 });
38 github.user.getFollowingFromUser({
39 user: "mikedeboer"
40 }, function(err, res) {
41 console.log(JSON.stringify(res));
6355ebe @fjakobs add readme
fjakobs authored
42 });
43
3f56822 @mikedeboer removed asyncjs as dev dependency and updated README unit testing ins…
mikedeboer authored
44 First the _GitHubApi_ class is imported from the _node-github_ module. This class provides
45 access to all of GitHub's APIs (e.g. user, issues or repo APIs). The _getFollowingFromUser_
46 method lists all followers of a given GitHub user. Is is part of the user API. It
47 takes the user name as first argument and a callback as last argument. Once the
4981dca @mikedeboer move from https://github.com/c9/node-github3 to https://github.com/aj…
mikedeboer authored
48 follower list is returned from the server, the callback is called.
6355ebe @fjakobs add readme
fjakobs authored
49
3f56822 @mikedeboer removed asyncjs as dev dependency and updated README unit testing ins…
mikedeboer authored
50 Like in Node.JS, callbacks are always the last argument. If the functions fails an
4981dca @mikedeboer move from https://github.com/c9/node-github3 to https://github.com/aj…
mikedeboer authored
51 error object is passed as first argument to the callback.
6355ebe @fjakobs add readme
fjakobs authored
52
4c4877a Fixing the readme to show the proper way to run the tests. Also upda…
Marc Campbell authored
53 ## Authentication
6355ebe @fjakobs add readme
fjakobs authored
54
3f56822 @mikedeboer removed asyncjs as dev dependency and updated README unit testing ins…
mikedeboer authored
55 Most GitHub API calls don't require authentication. As a rule of thumb: If you
56 can see the information by visiting the site without being logged in, you don't
57 have to be authenticated to retrieve the same information through the API. Of
4981dca @mikedeboer move from https://github.com/c9/node-github3 to https://github.com/aj…
mikedeboer authored
58 course calls, which change data or read sensitive information have to be authenticated.
6355ebe @fjakobs add readme
fjakobs authored
59
4981dca @mikedeboer move from https://github.com/c9/node-github3 to https://github.com/aj…
mikedeboer authored
60 You need the GitHub user name and the API key for authentication. The API key can
61 be found in the user's _Account Settings_ page.
6355ebe @fjakobs add readme
fjakobs authored
62
3f56822 @mikedeboer removed asyncjs as dev dependency and updated README unit testing ins…
mikedeboer authored
63 This example shows how to authenticate and then change _location_ field of the
4981dca @mikedeboer move from https://github.com/c9/node-github3 to https://github.com/aj…
mikedeboer authored
64 account settings to _Argentina_:
6355ebe @fjakobs add readme
fjakobs authored
65
4981dca @mikedeboer move from https://github.com/c9/node-github3 to https://github.com/aj…
mikedeboer authored
66 github.authenticate({
67 type: "basic",
68 username: username,
69 password: password
70 });
71 github.user.update({
72 location: "Argentina"
73 }, function(err) {
92ddfaa @fjakobs fix readme
fjakobs authored
74 console.log("done!");
6355ebe @fjakobs add readme
fjakobs authored
75 });
76
3f56822 @mikedeboer removed asyncjs as dev dependency and updated README unit testing ins…
mikedeboer authored
77 Note that the _authenticate_ method is synchronous because it only stores the
4981dca @mikedeboer move from https://github.com/c9/node-github3 to https://github.com/aj…
mikedeboer authored
78 credentials for the next request.
6355ebe @fjakobs add readme
fjakobs authored
79
ff58896 @mikedeboer documented all possible authentication methods
mikedeboer authored
80 Other examples for the various authentication methods:
81
82 // OAuth2
83 github.authenticate({
84 type: "oauth",
85 token: token
86 });
3f56822 @mikedeboer removed asyncjs as dev dependency and updated README unit testing ins…
mikedeboer authored
87
ff58896 @mikedeboer documented all possible authentication methods
mikedeboer authored
88 // Deprecated Gihub API token (seems not to be working with the v3 API)
89 github.authenticate({
90 type: "token",
91 token: token
92 });
93
bdedde6 @fjakobs Add information about implementation status
fjakobs authored
94 ## Implemented GitHub APIs
95
4981dca @mikedeboer move from https://github.com/c9/node-github3 to https://github.com/aj…
mikedeboer authored
96 * Gists: 100%
97 * Git Data: 100%
98 * Issues: 100%
99 * Orgs: 100%
100 * Pull Requests: 100%
101 * Repos: 100%
102 * Users: 100%
103 * Events: 100%
3f56822 @mikedeboer removed asyncjs as dev dependency and updated README unit testing ins…
mikedeboer authored
104 * Search: 100%
105 * Markdown: 100%
bdedde6 @fjakobs Add information about implementation status
fjakobs authored
106
6355ebe @fjakobs add readme
fjakobs authored
107 ## Running the Tests
108
3f56822 @mikedeboer removed asyncjs as dev dependency and updated README unit testing ins…
mikedeboer authored
109 The unit tests are based on the [mocha](http://visionmedia.github.com/mocha/)
110 module, which may be installed via npm. To run the tests make sure that the
4981dca @mikedeboer move from https://github.com/c9/node-github3 to https://github.com/aj…
mikedeboer authored
111 npm dependencies are installed by running `npm install` from the project directory.
aee368b @alexwhitman Update sys to util and remove where not used
alexwhitman authored
112
3f56822 @mikedeboer removed asyncjs as dev dependency and updated README unit testing ins…
mikedeboer authored
113 Before running unit tests:
34cab70 @fjakobs update readme
fjakobs authored
114
3f56822 @mikedeboer removed asyncjs as dev dependency and updated README unit testing ins…
mikedeboer authored
115 npm install mocha -g
aee368b @alexwhitman Update sys to util and remove where not used
alexwhitman authored
116
3f56822 @mikedeboer removed asyncjs as dev dependency and updated README unit testing ins…
mikedeboer authored
117 At the moment, test classes can only be run separately. This will e.g. run the Issues Api test:
6355ebe @fjakobs add readme
fjakobs authored
118
3f56822 @mikedeboer removed asyncjs as dev dependency and updated README unit testing ins…
mikedeboer authored
119 mocha api/v3.0.0/issuesTest.js
aee368b @alexwhitman Update sys to util and remove where not used
alexwhitman authored
120
6355ebe @fjakobs add readme
fjakobs authored
121 Note that a connection to the internet is required to run the tests.
122
123 ## LICENSE
124
76fa154 @fjakobs change wording
fjakobs authored
125 MIT license. See the LICENSE file for details.
Something went wrong with that request. Please try again.