22
33[ ![ Downloads per month] ( https://img.shields.io/npm/dm/github-api.svg?maxAge=2592000 )] [ npm-package ]
44[ ![ Latest version] ( https://img.shields.io/npm/v/github-api.svg?maxAge=3600 )] [ npm-package ]
5- [ ![ Gitter] ( https://img.shields.io/gitter/room/michael /github.js.svg?maxAge=2592000 )] [ gitter ]
6- [ ![ Travis] ( https://img.shields.io/travis/michael /github.svg?maxAge=60 )] [ travis-ci ]
7- <!-- [][codecov] -->
5+ [ ![ Gitter] ( https://img.shields.io/gitter/room/github-tools /github.js.svg?maxAge=2592000 )] [ gitter ]
6+ [ ![ Travis] ( https://img.shields.io/travis/github-tools /github.svg?maxAge=60 )] [ travis-ci ]
7+ [ ![ Codecov] ( https://img.shields.io/codecov/c/github/github-tools /github.svg?maxAge=2592000 )] [ codecov ]
88
9- Github.js provides a minimal higher-level wrapper around Github's API. It was concieved in the context of
10- [ Prose] [ prose ] , a content editor for GitHub.
9+ Github.js provides a minimal higher-level wrapper around Github's API.
1110
12- ## [ Read the docs] [ docs ]
13-
14- ## Installation
15- Github.js is available from ` npm ` or [ unpkg] [ unpkg ] .
16-
17- ``` shell
18- npm install github-api
19- ```
20-
21- ``` html
22- <!-- just github-api source (5.3kb) -->
23- <script src =" https://unpkg.com/github-api/dist/GitHub.min.js" ></script >
24-
25- <!-- standalone (20.3kb) -->
26- <script src =" https://unpkg.com/github-api/dist/GitHub.bundle.min.js" ></script >
27- ```
28-
29- ## Compatibility
30- Github.js is tested on Node:
31- * 6.x
32- * 5.x
33- * 4.x
34- * 0.12
35-
36- ## GitHub Tools
37-
38- The team behind Github.js has created a whole organization, called [ GitHub Tools] ( https://github.com/github-tools ) ,
39- dedicated to GitHub and its API. In the near future this repository could be moved under the GitHub Tools organization
40- as well. In the meantime, we recommend you to take a look at other projects of the organization.
41-
42- ## Samples
11+ ## Usage
4312
4413``` javascript
4514/*
4615 Data can be retrieved from the API either using callbacks (as in versions < 1.0)
47- or using a new promise-based API. For now the promise-based API just returns the
48- raw HTTP request promise; this might change in the next version .
16+ or using a new promise-based API. The promise-based API returns the raw Axios
17+ request promise.
4918 */
5019import GitHub from ' github-api' ;
5120
@@ -62,57 +31,66 @@ gist.create({
6231 }
6332}).then (function ({data}) {
6433 // Promises!
65- let gistJson = data;
66- gist .read (function (err , gist , xhr ) {
67- // if no error occurred then err == null
68-
69- // gistJson === httpResponse.data
70-
71- // xhr === httpResponse
72- });
34+ let createdGist = data;
35+ return gist .read ();
36+ }).then (function ({data}) {
37+ let retrievedGist = data;
38+ // do interesting things
7339});
7440```
7541
7642``` javascript
77- import GitHub from ' github-api' ;
43+ var GitHub = require ( ' github-api' ) ;
7844
7945// basic auth
80- const gh = new GitHub ({
46+ var gh = new GitHub ({
8147 username: ' FOO' ,
8248 password: ' NotFoo'
49+ /* also acceptable:
50+ token: 'MY_OAUTH_TOKEN'
51+ */
8352});
8453
85- const me = gh .getUser ();
54+ var me = gh .getUser (); // no user specified defaults to the user for whom credentials were provided
8655me .listNotifications (function (err , notifications ) {
8756 // do some stuff
8857});
8958
90- const clayreimann = gh .getUser (' clayreimann' );
91- clayreimann .listStarredRepos ()
92- .then (function ({data: reposJson}) {
93- // do stuff with reposJson
94- });
59+ var clayreimann = gh .getUser (' clayreimann' );
60+ clayreimann .listStarredRepos (function (err , repos ) {
61+ // look at all the starred repos!
62+ });
9563```
9664
97- ``` javascript
98- var GitHub = require (' github-api' );
65+ ## API Documentation
9966
100- // token auth
101- var gh = new GitHub ({
102- token: ' MY_OAUTH_TOKEN'
103- });
67+ [ API documentation] [ docs ] is hosted on github pages, and is generated from JSDoc; any contributions
68+ should include updated JSDoc.
69+
70+ ## Installation
71+ Github.js is available from ` npm ` or [ unpkg] [ unpkg ] .
10472
105- var yahoo = gh .getOrganization (' yahoo' );
106- yahoo .listRepos (function (err , repos ) {
107- // look at all the repos!
108- })
73+ ``` shell
74+ npm install github-api
10975```
11076
111- [ codecov ] : https://codecov.io/github/michael/github?branch=master
77+ ``` html
78+ <!-- just github-api source (5.3kb) -->
79+ <script src =" https://unpkg.com/github-api/dist/GitHub.min.js" ></script >
80+
81+ <!-- standalone (20.3kb) -->
82+ <script src =" https://unpkg.com/github-api/dist/GitHub.bundle.min.js" ></script >
83+ ```
84+
85+ ## Compatibility
86+ ` Github.js ` is tested on Node.js:
87+ * 6.x
88+
89+ Note: ` Github.js ` uses Promise, hence it will not work in Node.js < 4 without polyfill.
90+
91+ [ codecov ] : https://codecov.io/github/github-tools/github?branch=master
11292[ docs ] : http://github-tools.github.io/github/
113- [ gitter ] : https://gitter.im/michael /github
93+ [ gitter ] : https://gitter.im/github-tools /github
11494[ npm-package ] : https://www.npmjs.com/package/github-api/
11595[ unpkg ] : https://unpkg.com/github-api/
116- [ prose ] : http://prose.io
117- [ travis-ci ] : https://travis-ci.org/michael/github
118- [ xhr-link ] : http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx
96+ [ travis-ci ] : https://travis-ci.org/github-tools/github
0 commit comments