Coder Social home page Coder Social logo

doowb / github-traffic Goto Github PK

View Code? Open in Web Editor NEW
81.0 4.0 10.0 22 KB

Get the Github traffic for the specified repository

License: MIT License

JavaScript 100.00%
github github-api api github-traffic traffic stats analytics github-stats statistics github-statistics

github-traffic's Introduction

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.

github-traffic's People

Contributors

doowb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.