{"id":17301851,"url":"https://github.com/seladb/github-traffic-stats","last_synced_at":"2025-04-14T12:42:33.103Z","repository":{"id":29901880,"uuid":"122458973","full_name":"seladb/github-traffic-stats","owner":"seladb","description":"A small Python project to pull and store traffic stats for GitHub projects using GitHub API","archived":false,"fork":false,"pushed_at":"2022-02-28T14:00:31.000Z","size":29,"stargazers_count":28,"open_issues_count":2,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-21T19:16:14.703Z","etag":null,"topics":["github-api","github-traffic","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seladb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-22T09:45:03.000Z","updated_at":"2024-09-16T20:08:33.000Z","dependencies_parsed_at":"2022-08-07T14:31:04.313Z","dependency_job_id":null,"html_url":"https://github.com/seladb/github-traffic-stats","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seladb%2Fgithub-traffic-stats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seladb%2Fgithub-traffic-stats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seladb%2Fgithub-traffic-stats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seladb%2Fgithub-traffic-stats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seladb","download_url":"https://codeload.github.com/seladb/github-traffic-stats/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248883185,"owners_count":21177174,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github-api","github-traffic","python"],"created_at":"2024-10-15T11:45:44.823Z","updated_at":"2025-04-14T12:42:33.077Z","avatar_url":"https://github.com/seladb.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GitHub Traffic Stats\n\n[![PyPI](https://img.shields.io/pypi/v/github-traffic-stats2)](https://pypi.org/project/github-traffic-stats2/)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/github-traffic-stats2)](https://www.python.org/download/releases/3.0/)\n![Python test](https://github.com/seladb/github-traffic-stats/workflows/Python%20test/badge.svg)\n\nA small Python project to pull and store traffic stats for GitHub projects using GitHub API.\n\nCurrently GitHub provides only 14 days of traffic data to a repo. This data includes the number of views and the number of unique visitors for each day. \n\nBut what happens if you want to store and view more than 14 days of data?\nThis script aims to collect and aggregate the data and then store it in a simple NoSQL DB which can later be viewed and analyzed.\n\n\n## Table Of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [License](#license)\n\n## Installation ##\n\nThis script requires Python 3 (Python 2.7 is no longer supported).\n\nThe requirements for this script are described in [requirements.txt](https://github.com/seladb/github-traffic-stats/blob/master/requirements.txt).\n\n### Installation with pip: ###\n```\npip install github_traffic_stats2\n```\nIf you choose this option you'll be able to run the script simply by typing `github_traffic_stats`\n\n### Installation without virtualenv: ###\n```\npython pip install -r requirements.txt\n```\n\n### Installation with virtualenv (linux/Mac): ###\n```\n$ virtualenv venv\nNew python executable in venv/bin/python\nInstalling distribute.........done.\nInstalling pip................done.\n$ source venv/bin/activate\n(venv)$ pip install -r requirements.txt\nCollecting githubpy==1.1.0 (from -r requirements.txt (line 1))\nCollecting pickleDB==0.9.2 (from -r requirements.txt (line 2))\nCollecting simplejson==3.17.0 (from -r requirements.txt (line 3))\nInstalling collected packages: githubpy, simplejson, pickleDB\nSuccessfully installed githubpy-1.1.0 pickleDB-0.9.2 simplejson-3.17.0\n(venv)$\n```\n\n## Usage ##\n\nThere are 3 modes of operation: **collect**, **view** and **exportcsv**\n\n### Collect ###\n\nCollect last 14-days traffic data from GitHub and store it in the DB. The DB is pickleDB which is a really simple NoSQL DB which is stored in a local file.\n\nUsage:\n\n#### Collect traffic data for a repo: ####\n\n`python github_traffic_stats.py collect -u [github-user] -r [github-repo] -t [github-access-token]`\n\nWhere:\n - `[github-user]` is the GitHub user who owns this repo\n - `[github-repo]` is the GitHub repository to pull stats on\n - `[github-access-token]` is the GitHub personal access token\n\nExample:\n\n```\npython github_traffic_stats.py collect -u seladb -r pcapplusplus -t ******\n2018-02-22T00:00:00Z {'count': 153, 'uniques': 45}\n```\n\n#### Collect traffic data for an organization repo: ####\n\n`python github_traffic_stats.py collect -o [github-org] -u [github-user] -r [github-repo] -t [github-access-token]`\n\nWhere:\n - `[github-org]` is the repo organization (for example: google for repo protobuf)\n - `[github-user]` is the GitHub user who has access to traffic stats in this repo\n - `[github-repo]` is the GitHub repository to pull stats on\n - `[github-access-token]` is the GitHub personal access token\n\nExample:\n\n```\npython github_traffic_stats.py collect -o pcapplusplus -u seladb -r pcapplusplus.github.io -t ******\n2020-05-27T00:00:00Z {\"uniques\": 2, \"count\": 6}\n```\n\n### View ###\n \n Open the DB file, read all the data stored and output is to console, sorted by timestamp.\n \n Usage:\n \n `python github_traffic_stats.py view -r [github-repo]`\n \n Where:\n - `[github-repo]` is the GitHub repository to pull stats on\n\nExample:\n```\npython github_traffic_stats.py view -r pcapplusplus\n2020-05-15T00:00:00Z {\"uniques\": 41, \"count\": 162}\n2020-05-16T00:00:00Z {\"uniques\": 32, \"count\": 149}\n2020-05-17T00:00:00Z {\"uniques\": 38, \"count\": 177}\n2020-05-18T00:00:00Z {\"uniques\": 63, \"count\": 291}\n2020-05-19T00:00:00Z {\"uniques\": 92, \"count\": 412}\n2020-05-20T00:00:00Z {\"uniques\": 68, \"count\": 277}\n2020-05-21T00:00:00Z {\"uniques\": 75, \"count\": 381}\n2020-05-22T00:00:00Z {\"uniques\": 55, \"count\": 323}\n2020-05-23T00:00:00Z {\"uniques\": 36, \"count\": 185}\n2020-05-24T00:00:00Z {\"uniques\": 32, \"count\": 193}\n2020-05-25T00:00:00Z {\"uniques\": 75, \"count\": 317}\n2020-05-26T00:00:00Z {\"uniques\": 67, \"count\": 360}\n2020-05-27T00:00:00Z {\"uniques\": 71, \"count\": 403}\n2020-05-28T00:00:00Z {\"uniques\": 67, \"count\": 340}\n2020-05-29T00:00:00Z {\"uniques\": 18, \"count\": 82}\n15 elements\n```\n\n### exportcsv ###\n\nExport the DB into a csv file with the format of `[repo_name].csv`\n\nUsage:\n \n `python github_traffic_stats.py exportcsv -r [github-repo]`\n \n Where:\n - `[github-repo]` is the GitHub repository to pull stats on\n\nExample:\n```\npython github_traffic_stats.py exportcsv -r pcapplusplus\npcapplusplus.csv written to disk\n```\n\n## License\n\ngithub-traffic-stats is released under the [MIT](https://en.wikipedia.org/wiki/MIT_License) license.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseladb%2Fgithub-traffic-stats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseladb%2Fgithub-traffic-stats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseladb%2Fgithub-traffic-stats/lists"}