node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »



Gets the contents of a file from a public Github repo using the github API.


npm install github-contents

example usage

var getContents = require('github-contents');
getContents('lib/xmlrpc-router.js', function (err, contents) {


  • uses the official github API and therefore stable (getting files via raw http address is going away).


  • fimited to 60 requests per hour (as per standard github policy for unauthenticated requests).
  • fetches the entire file's contents at once. A streaming method for low memory-consumption would be preferable.


At some point I'd like to add a few more methods / options:

  • allow authentication so as to be able to make more requests per hour and/or for getting contents from a private repo
  • add a streaming method for low memory-consumption so that this could be run on a VPS without worrying about memory usage.
  • possibly some other file-related methods, maybe even something like a fs module that works through github transparently

feel free to send PR for the above, other features, etc.


Tests require mocha to be installed.

$ mocha


MIT Style License (see LICENSE.txt)