Skip to content

Latest commit

 

History

History
244 lines (182 loc) · 10.8 KB

README.md

File metadata and controls

244 lines (182 loc) · 10.8 KB

github-traffic NPM version NPM downloads Build Status

Get the Github traffic for the specified repository

Install

Install with npm:

$ npm install --save github-traffic

Usage

var traffic = require('github-traffic');

API

Get the last 14 days (this is Github's limitation) of Github traffic for the specified repository. The results will contain 4 keys (one for each of the traffic endpoints specified in the api documentation). See the example results for the expanded results from the example. See the other methods below to get results for a specific endpoint.

Params

  • repo {String}: Full repository to get traffic, formatted as :owner/:repo. If the repository is published to NPM, the NPM name may be used.
  • options {Object}: Options containing the Github authentication information. This is required since user's must be administrators on the repository to retrieve traffic information.
  • options.username {String}: Github username of the repository administrator retrieving the traffic information. This is required if an oauth token is not used.
  • options.password {String}: Github user's password of the repository administrator retrieving the traffic information. This is required if an oauth token is not used.
  • options.token {String}: Github oauth token for the repository administrator retrieving the traffic informatino. This is required if the username/password combination is not used.
  • cb {Function}: Optional callback function that will be called with error information or the results. When omitted a Promise is returned.
  • returns {Promise}: Promise with the traffic information when ready.

Example

var options = {
  username: 'doowb',
  password: '**********'
};

traffic('assemble/assemble', options, function(err, results) {
  if (err) return console.error(err);
  console.log(results);
  //=> {
  //=>   referrers: [ ... ],
  //=>   paths: [ ... ],
  //=>   views: {
  //=>     count: 4043,
  //=>     uniques: 1155,
  //=>     views: [ ... ]
  //=>   },
  //=>   clones: {
  //=>     count: 47,
  //=>     uniques: 38,
  //=>     clones: [ ... ]
  //=>   }
  //=> }
});

Get referrers for the specified repository from the Github traffic api.

Params

  • repo {String}: Full repository to get traffic, formatted as :owner/:repo. If the repository is published to NPM, the NPM name may be used.
  • options {Object}: Options containing the Github authentication information. This is required since user's must be administrators on the repository to retrieve traffic information.
  • options.username {String}: Github username of the repository administrator retrieving the traffic information. This is required if an oauth token is not used.
  • options.password {String}: Github user's password of the repository administrator retrieving the traffic information. This is required if an oauth token is not used.
  • options.token {String}: Github oauth token for the repository administrator retrieving the traffic informatino. This is required if the username/password combination is not used.
  • cb {Function}: Optional callback function that will be called with error information or the results. When omitted a Promise is returned.
  • returns {Promise}: Promise with the traffic information when ready.

Example

var options = {
  username: 'doowb',
  password: '**********'
};

traffic.referrers('assemble/assemble', options, function(err, results) {
  if (err) return console.error(err);
  console.log(results);
  //=> [
  //=>   { referrer: 'Google', count: 765, uniques: 377 },
  //=>   ...
  //=> ],
});

Get paths for the specified repository from the Github traffic api.

Params

  • repo {String}: Full repository to get traffic, formatted as :owner/:repo. If the repository is published to NPM, the NPM name may be used.
  • options {Object}: Options containing the Github authentication information. This is required since user's must be administrators on the repository to retrieve traffic information.
  • options.username {String}: Github username of the repository administrator retrieving the traffic information. This is required if an oauth token is not used.
  • options.password {String}: Github user's password of the repository administrator retrieving the traffic information. This is required if an oauth token is not used.
  • options.token {String}: Github oauth token for the repository administrator retrieving the traffic informatino. This is required if the username/password combination is not used.
  • cb {Function}: Optional callback function that will be called with error information or the results. When omitted a Promise is returned.
  • returns {Promise}: Promise with the traffic information when ready.

Example

var options = {
  username: 'doowb',
  password: '**********'
};

traffic.paths('assemble/assemble', options, function(err, results) {
  if (err) return console.error(err);
  console.log(results);
  //=> [
  //=>   {
  //=>     path: '/assemble/assemble',
  //=>     title: 'GitHub - assemble/assemble: Static site generator and rapid prototyping frame...',
  //=>     count: 1551,
  //=>     uniques: 839
  //=>   },
  //=>   ...
  //=> ],
});

Get views for the specified repository from the Github traffic api.

Params

  • repo {String}: Full repository to get traffic, formatted as :owner/:repo. If the repository is published to NPM, the NPM name may be used.
  • options {Object}: Options containing the Github authentication information. This is required since user's must be administrators on the repository to retrieve traffic information.
  • options.username {String}: Github username of the repository administrator retrieving the traffic information. This is required if an oauth token is not used.
  • options.password {String}: Github user's password of the repository administrator retrieving the traffic information. This is required if an oauth token is not used.
  • options.token {String}: Github oauth token for the repository administrator retrieving the traffic informatino. This is required if the username/password combination is not used.
  • cb {Function}: Optional callback function that will be called with error information or the results. When omitted a Promise is returned.
  • returns {Promise}: Promise with the traffic information when ready.

Example

var options = {
  username: 'doowb',
  password: '**********'
};

traffic.views('assemble/assemble', options, function(err, results) {
  if (err) return console.error(err);
  console.log(results);
  //=> {
  //=>   count: 4043,
  //=>   uniques: 1155,
  //=>   views: [ ... ]
  //=> }
});

Get clones for the specified repository from the Github traffic api.

Params

  • repo {String}: Full repository to get traffic, formatted as :owner/:repo. If the repository is published to NPM, the NPM name may be used.
  • options {Object}: Options containing the Github authentication information. This is required since user's must be administrators on the repository to retrieve traffic information.
  • options.username {String}: Github username of the repository administrator retrieving the traffic information. This is required if an oauth token is not used.
  • options.password {String}: Github user's password of the repository administrator retrieving the traffic information. This is required if an oauth token is not used.
  • options.token {String}: Github oauth token for the repository administrator retrieving the traffic informatino. This is required if the username/password combination is not used.
  • cb {Function}: Optional callback function that will be called with error information or the results. When omitted a Promise is returned.
  • returns {Promise}: Promise with the traffic information when ready.

Example

var options = {
  username: 'doowb',
  password: '**********'
};

traffic.clones('assemble/assemble', options, function(err, results) {
  if (err) return console.error(err);
  console.log(results);
  //=> {
  //=>   count: 47,
  //=>   uniques: 38,
  //=>   clones: [ ... ]
  //=> }
});

About

Related projects

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Please read the contributing guide for avice on opening issues, pull requests, and coding standards.

Building docs

(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)

To generate the readme and API documentation with verb:

$ npm install -g verb verb-generate-readme && verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Brian Woodward

License

Copyright © 2016, Brian Woodward. Released under the MIT license.


This file was generated by verb-generate-readme, v0.1.30, on September 16, 2016.