66[ ![ Travis] ( https://img.shields.io/travis/michael/github.svg?maxAge=60 )] [ travis-ci ]
77<!-- [][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,52 +31,70 @@ 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.
10469
105- var yahoo = gh .getOrganization (' yahoo' );
106- yahoo .listRepos (function (err , repos ) {
107- // look at all the repos!
108- })
70+ ## Installation
71+ Github.js is available from ` npm ` or [ unpkg] [ unpkg ] .
72+
73+ ``` shell
74+ npm install github-api
10975```
11076
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:
87+ * 6.x
88+ * 5.x
89+ * 4.x
90+ * 0.12
91+
92+ ## GitHub Tools
93+
94+ The team behind Github.js has created a whole organization, called [ GitHub Tools] ( https://github.com/github-tools ) ,
95+ dedicated to GitHub and its API. In the near future this repository could be moved under the GitHub Tools organization
96+ as well. In the meantime, we recommend you to take a look at other projects of the organization.
97+
11198[ codecov ] : https://codecov.io/github/michael/github?branch=master
11299[ docs ] : http://michael.github.io/github/
113100[ gitter ] : https://gitter.im/michael/github
0 commit comments