Skip to content

Commit 4981dca

Browse files
committed
1 parent 62b7735 commit 4981dca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+13889
-2864
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License
22

3-
Copyright (c) 2010 ajax.org B.V (Fabian Jakobs)
3+
Copyright (c) 2012 Cloud9 IDE, Inc. (Mike de Boer)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

NOTICE.txt

Lines changed: 0 additions & 10 deletions
This file was deleted.

README.md

Lines changed: 61 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,114 @@
1-
# JavaScript GitHub API for node.js
1+
# JavaScript GitHub API for Node.JS
22

3-
A node.js module, which provides an object oriented wrapper for the GitHub v2 API. This library is a direct port of [php-github-api](http://github.com/ornicar/php-github-api) by Thibault Duplessis to JavaScript. The only major difference is that the JavaScript code is fully asynchronous.
3+
A Node.JS module, which provides an object oriented wrapper for the GitHub v3 API.
44

55
## Installation
66

7-
Install with the node package manager [npm](http://npmjs.org/):
7+
Install with the Node.JS package manager [npm](http://npmjs.org/):
88

9-
$ npm install github
9+
$ npm install node-github
1010

1111
or
1212

1313
Install via git clone:
1414

15-
$ git clone git://github.com/ajaxorg/node-github.git
16-
$ cd node-github
15+
$ git clone git://github.com/c9/node-github3.git
16+
$ cd node-github3
1717
$ npm install
1818

19+
## Documentation
20+
21+
You can find the docs for the API of this client at [http://c9.github.com/node-github3/](http://c9.github.com/node-github3/)
22+
23+
Additionally, the [official Github documentation](http://developer.github.com/)
24+
is a very useful resource.
25+
1926
## Example
2027

21-
Print all followers of the user "fjakobs" to the console.
28+
Print all followers of the user "mikedeboer" to the console.
2229

23-
var GitHubApi = require("github").GitHubApi;
30+
var GitHubApi = require("node-github");
2431

25-
var github = new GitHubApi(true);
26-
github.getUserApi().getFollowers('fjakobs', function(err, followers) {
27-
console.log(followers.join('\n'));
32+
var github = new GitHubApi({
33+
version: "3.0.0"
34+
});
35+
github.user.getFollowingFromUser({
36+
user: "mikedeboer"
37+
}, function(err, res) {
38+
console.log(JSON.stringify(res));
2839
});
2940

30-
First the _GitHubApi_ class is imported from the _github_ module. This class provides access to all of GitHub's APIs (e.g. user, commit or repository APIs). The _getFollowers_ method lists all followers of a given GitHub user. Is is part of the user API. It takes the user name as first argument and a callback as last argument. Once the follower list is returned from the server, the callback is called.
41+
First the _GitHubApi_ class is imported from the _node-github_ module. This class provides
42+
access to all of GitHub's APIs (e.g. user, issues or repo APIs). The _getFollowingFromUser_
43+
method lists all followers of a given GitHub user. Is is part of the user API. It
44+
takes the user name as first argument and a callback as last argument. Once the
45+
follower list is returned from the server, the callback is called.
3146

32-
Like in node.js callbacks are always the last argument. If the functions fails an error object is passed as first argument to the callback.
47+
Like in Node.JS, callbacks are always the last argument. If the functions fails an
48+
error object is passed as first argument to the callback.
3349

3450
## Authentication
3551

36-
Most GitHub API calls don't require authentication. As a rule of thumb: If you can see the information by visiting the site without being logged in, you don't have to be authenticated to retrieve the same information through the API. Of course calls, which change data or read sensitive information have to be authenticated.
52+
Most GitHub API calls don't require authentication. As a rule of thumb: If you
53+
can see the information by visiting the site without being logged in, you don't
54+
have to be authenticated to retrieve the same information through the API. Of
55+
course calls, which change data or read sensitive information have to be authenticated.
3756

38-
You need the GitHub user name and the API key for authentication. The API key can be found in the user's _Account Settings_ page.
57+
You need the GitHub user name and the API key for authentication. The API key can
58+
be found in the user's _Account Settings_ page.
3959

40-
This example shows how to authenticate and then change _location_ field of the account settings to _Argentina_:
60+
This example shows how to authenticate and then change _location_ field of the
61+
account settings to _Argentina_:
4162

42-
github.authenticate(username, token);
43-
github.getUserApi().update(username, {location: "Argentina"}, function(err) {
63+
github.authenticate({
64+
type: "basic",
65+
username: username,
66+
password: password
67+
});
68+
github.user.update({
69+
location: "Argentina"
70+
}, function(err) {
4471
console.log("done!");
4572
});
4673

47-
Note that the _authenticate_ method is synchronous because it only stores the credentials for the next request.
74+
Note that the _authenticate_ method is synchronous because it only stores the
75+
credentials for the next request.
4876

4977
## Implemented GitHub APIs
5078

51-
* User API: 100%
52-
* Commit API: 100%
53-
* Object API: 100%
54-
* Repository API: 90%, missing repo visibility, deploy keys
55-
* Issues API: 100%
56-
* Pulls API: only _getList_ is implemented
57-
* Gist API: 100% v1 Gist API implemented. 0% v3 API
58-
* Network API: still missing
79+
* Gists: 100%
80+
* Git Data: 100%
81+
* Issues: 100%
82+
* Orgs: 100%
83+
* Pull Requests: 100%
84+
* Repos: 100%
85+
* Users: 100%
86+
* Events: 100%
5987

6088
## Running the Tests
6189

62-
The unit tests are based on the [node-async-test](http://github.com/bentomas/node-async-testing) module, which is provided as a git submodule. To run the tests make sure that the npm dependencies are installed by running `npm install` from the project directory.
90+
The unit tests are based on the [ayncjs](https://github.com/ajaxorg/async.js)
91+
module, which is provided as an npm dependency. To run the tests make sure that the
92+
npm dependencies are installed by running `npm install` from the project directory.
6393

6494
Running all unit tests:
6595

6696
npm test
6797

6898
or
6999

70-
node lib/github_all_tests.js
100+
node test/all.js
71101

72102
The test classes can also be run separately. This will e.g. run the UserApi test:
73103

74-
node lib/github_test.js
104+
node api/v3.0.0/userTest.js
75105

76106
Note that a connection to the internet is required to run the tests.
77107

78108
## TODO
79109

80-
* API docs
81-
* fix and polish (there might still be some PHP-isms)
82-
* generate API documentation
83-
* Documentation
110+
* generate Client documentation
84111

85112
## LICENSE
86113

87114
MIT license. See the LICENSE file for details.
88-
89-
## Credits
90-
91-
Thanks to Thibault Duplessis for the excellent php-github-api library, which is the blueprint of this library. Especially the unit tests proved to be very helpful.

api/v2.0.0/routes.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
3+
}

0 commit comments

Comments
 (0)