{ "name": "github", "version": "0.2.4", "description": "NodeJS wrapper for the GitHub API", "author": { "name": "Mike de Boer", "email": "info@mikedeboer.nl" }, "contributors": [ { "name": "Mike de Boer", "email": "info@mikedeboer.nl" }, { "name": "Fabian Jakobs", "email": "fabian@c9.io" } ], "homepage": "http://github.com/mikedeboer/node-github", "repository": { "type": "git", "url": "git+ssh://git@github.com/mikedeboer/node-github.git" }, "engine": { "node": ">=0.4.0" }, "dependencies": { "mime": "^1.2.11" }, "devDependencies": { "oauth": "~0.9.7", "optimist": "~0.6.0", "mocha": "~1.13.0" }, "main": ".", "scripts": { "test": "node ./test/all.js" }, "licenses": [ { "type": "The MIT License", "url": "http://www.opensource.org/licenses/mit-license.php" } ], "readme": "# JavaScript GitHub API for Node.JS\n\nA Node.JS module, which provides an object oriented wrapper for the GitHub v3 API.\n\n## Installation\n\n Install with the Node.JS package manager [npm](http://npmjs.org/) ![NPM version](https://badge.fury.io/js/github.svg):\n\n $ npm install github\n\nor\n\n Install via git clone:\n\n $ git clone git://github.com/mikedeboer/node-github.git\n $ cd node-github\n $ npm install\n\n## Documentation\n\nYou can find the docs for the API of this client at [http://mikedeboer.github.com/node-github/](http://mikedeboer.github.com/node-github/)\n\nAdditionally, the [official Github documentation](https://developer.github.com/v3/)\nis a very useful resource.\n\n## Example\n\nPrint all followers of the user \"mikedeboer\" to the console.\n```javascript\nvar GitHubApi = require(\"github\");\n\nvar github = new GitHubApi({\n // required\n version: \"3.0.0\",\n // optional\n debug: true,\n protocol: \"https\",\n host: \"github.my-GHE-enabled-company.com\", // should be api.github.com for GitHub\n pathPrefix: \"/api/v3\", // for some GHEs; none for GitHub\n timeout: 5000,\n headers: {\n \"user-agent\": \"My-Cool-GitHub-App\" // GitHub is happy with a unique user agent\n }\n});\ngithub.user.getFollowingFromUser({\n // optional:\n // headers: {\n // \"cookie\": \"blahblah\"\n // },\n user: \"mikedeboer\"\n}, function(err, res) {\n console.log(JSON.stringify(res));\n});\n```\n\nFirst the _GitHubApi_ class is imported from the _node-github_ module. This class provides\naccess to all of GitHub's APIs (e.g. user, issues or repo APIs). The _getFollowingFromUser_\nmethod lists all followers of a given GitHub user. Is is part of the user API. It\ntakes the user name as first argument and a callback as last argument. Once the\nfollower list is returned from the server, the callback is called.\n\nLike in Node.JS, callbacks are always the last argument. If the functions fails an\nerror object is passed as first argument to the callback.\n\n## Authentication\n\nMost GitHub API calls don't require authentication. As a rule of thumb: If you\ncan see the information by visiting the site without being logged in, you don't\nhave to be authenticated to retrieve the same information through the API. Of\ncourse calls, which change data or read sensitive information have to be authenticated.\n\nYou need the GitHub user name and the API key for authentication. The API key can\nbe found in the user's _Account Settings_ page.\n\nThis example shows how to authenticate and then change _location_ field of the\naccount settings to _Argentina_:\n```javascript\ngithub.authenticate({\n type: \"basic\",\n username: username,\n password: password\n});\ngithub.user.update({\n location: \"Argentina\"\n}, function(err) {\n console.log(\"done!\");\n});\n```\nNote that the _authenticate_ method is synchronous because it only stores the\ncredentials for the next request.\n\nOther examples for the various authentication methods:\n```javascript\n// OAuth2\ngithub.authenticate({\n type: \"oauth\",\n token: token\n});\n\n// OAuth2 Key/Secret\ngithub.authenticate({\n type: \"oauth\",\n key: \"clientID\",\n secret: \"clientSecret\"\n})\n\n// Deprecated Gihub API token (seems not to be working with the v3 API)\ngithub.authenticate({\n type: \"token\",\n token: token\n});\n```\n\n### Creating tokens for your application\n[Create a new authorization](http://developer.github.com/v3/oauth/#create-a-new-authorization) for your application giving it access to the wanted scopes you need instead of relying on username / password and is the way to go if you have [two-factor authentication](https://github.com/blog/1614-two-factor-authentication) on.\n\nFor example:\n\n1. Use github.authenticate() to auth with GitHub using your username / password\n2. Create an application token programmatically with the scopes you need and, if you use two-factor authentication send the `X-GitHub-OTP` header with the one-time-password you get on your token device.\n\n```javascript\ngithub.authorization.create({\n scopes: [\"user\", \"public_repo\", \"repo\", \"repo:status\", \"gist\"],\n note: \"what this auth is for\",\n note_url: \"http://url-to-this-auth-app\",\n headers: {\n \"X-GitHub-OTP\": \"two-factor-code\"\n }\n}, function(err, res) {\n if (res.token) {\n //save and use res.token as in the Oauth process above from now on\n }\n});\n```\n\n## Implemented GitHub APIs\n\n* Gists: 100%\n* Git Data: 100%\n* Issues: 100%\n* Orgs: 100%\n* Pull Requests: 100%\n* Repos: 100%\n* Users: 100%\n* Events: 100%\n* Search: 100%\n* Markdown: 100%\n* Rate Limit: 100%\n* Releases: 100%\n* Gitignore: 100%\n* Meta: 100%\n* Emojis: 100%\n\n## Running the Tests\n\nThe unit tests are based on the [mocha](http://visionmedia.github.com/mocha/)\nmodule, which may be installed via npm. To run the tests make sure that the\nnpm dependencies are installed by running `npm install` from the project directory.\n\nBefore running unit tests:\n```shell\nnpm install mocha -g\n```\nAt the moment, test classes can only be run separately. This will e.g. run the Issues Api test:\n```shell\nmocha api/v3.0.0/issuesTest.js\n```\nNote that a connection to the internet is required to run the tests.\n\n## LICENSE\n\nMIT license. See the LICENSE file for details.\n", "readmeFilename": "README.md", "bugs": { "url": "https://github.com/mikedeboer/node-github/issues" }, "_id": "github@0.2.4", "_shasum": "24fa7f0e13fa11b946af91134c51982a91ce538b", "_resolved": "https://registry.npmjs.org/github/-/github-0.2.4.tgz", "_from": "github@>=0.2.3 <0.3.0" }