Skip to main content

Get statistics on web traffic to your GitHub repositories.

Project description

https://travis-ci.org/nchah/github-traffic-stats.svg?branch=master

Get statistics on web traffic to your GitHub repositories.

Python CLI

Python CLI tool to get web traffic stats on the command line using the GitHub API.

A few use cases to show why this may be useful.

  • Checking the volume of traffic to all of your repos. Monitor sudden spikes in interest or any general patterns.

  • Storing the traffic stats for future reference.

  • Checking how often your code is cloned.

Installation

pip install github_traffic_stats

Dependencies

Install the requirements by running:

pip install -r requirements.txt

There are a number of GitHub libraries for Python and other languages, although they may not support the Repository Traffic API (announced on August 15, 2016).

Usage

usage: gts [-h] username [repo] [save_csv] [-o]
   or:
usage: gts [-h] username:password [repo] [save_csv] [-o]

positional arguments:
  username    Github username
  password    Github password for 'username', or access token
  repo        User's repo
  save_csv    Set to "no_csv" if no CSV should be saved

optional arguments:
  -h, --help  show this help message and exit
  -o, --organization specify Github organization if different from username

Information on Github Access Tokens.

Run

Run on the command line with either python or python3.

$ gts 'nchah' 'github-traffic-stats' 'save_csv'
Password:* (passwords are hidden)
> github-traffic-stats - Visitors
Date        Views   Unique visitors
Totals      125     36
2017-07-16  1       1
2017-07-17  10      2
2017-07-19  11      4
2017-07-20  12      5
2017-07-21  3       3
2017-07-22  1       1
2017-07-23  1       1
2017-07-24  17      6
2017-07-25  32      5
2017-07-26  1       1
2017-07-27  1       1
2017-07-28  6       4
2017-07-29  26      5
2017-07-30  3       1

> github-traffic-stats - Git clones
Date        Clones  Unique cloners
Totals      5       5
2017-07-17  1       1
2017-07-24  2       2
2017-07-26  1       1
2017-07-29  1       1

> github-traffic-stats - Referring sites
Date        Views   Unique visitors
Totals      44      27
Google      33      24
github.c... 11      3


$ # Or to get stats on all of your repositories
$ gts 'nchah' 'ALL' 'save_csv'
Password:* (passwords are hidden)

$ # Or if you are running on an organization repo (for example NREL's SAM repo) as a user with access
$ gts 'nickdiorio' 'SAM' 'save_csv' -o 'NREL'
Password:* (passwords are hidden)
...

Traffic data stored in CSV files with columns:

repository_name, date, views, unique_visitors
Separate CSVs are created for each run of the script.
To merge and only preserve the unique data points, run:
$ bash bash/merge-csv.sh [folder_with_CSVs]

Documentation

A list of the references used for this project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

github_traffic_stats-1.2.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

github_traffic_stats-1.2.0-py2.py3-none-any.whl (6.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file github_traffic_stats-1.2.0.tar.gz.

File metadata

File hashes

Hashes for github_traffic_stats-1.2.0.tar.gz
Algorithm Hash digest
SHA256 ef6d9e4e64c7b80d57cacc0e34396194ff7a28d1f3705e7dbcd5a180f028ab9f
MD5 4e8c7249b6179a8bb9a6142a38f8d0fa
BLAKE2b-256 c8c21f11bce3fc6dc9bc68caa8af4d44af5bfc9dfe996d61a4cba2001613f05c

See more details on using hashes here.

File details

Details for the file github_traffic_stats-1.2.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for github_traffic_stats-1.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fc984441999eed56af81601233277b65fa3e79d6cc27c5306df005a99a51457d
MD5 7f5cdf8944b20b9a2751ea1651abf5a6
BLAKE2b-256 dee00544a6c3ab2b787fe04c0c0a001b9abd4d4e27137e9acaff253dbc29fccf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page