{"id":18840112,"url":"https://github.com/openupm/verdaccio-install-counts","last_synced_at":"2025-04-14T07:06:13.616Z","repository":{"id":169464949,"uuid":"645448258","full_name":"openupm/verdaccio-install-counts","owner":"openupm","description":"The package implements API endpoints for package download counts similar to NPM","archived":false,"fork":false,"pushed_at":"2023-10-26T15:09:54.000Z","size":233,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T20:44:35.484Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openupm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"patreon":"openupm"}},"created_at":"2023-05-25T17:14:43.000Z","updated_at":"2025-03-21T09:06:48.000Z","dependencies_parsed_at":"2023-10-13T03:13:05.652Z","dependency_job_id":null,"html_url":"https://github.com/openupm/verdaccio-install-counts","commit_stats":null,"previous_names":["openupm/verdaccio-download-counts","openupm/verdaccio-install-counts"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openupm%2Fverdaccio-install-counts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openupm%2Fverdaccio-install-counts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openupm%2Fverdaccio-install-counts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openupm%2Fverdaccio-install-counts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openupm","download_url":"https://codeload.github.com/openupm/verdaccio-install-counts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248581365,"owners_count":21128155,"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":[],"created_at":"2024-11-08T02:45:05.014Z","updated_at":"2025-04-14T07:06:13.540Z","avatar_url":"https://github.com/openupm.png","language":"TypeScript","funding_links":["https://patreon.com/openupm"],"categories":["TypeScript"],"sub_categories":[],"readme":"# verdaccio-install-counts\n\n\u003c!-- vscode-markdown-toc --\u003e\n* [Introduction](#Introduction)\n* [Install](#Install)\n* [API endpoints](#APIendpoints)\n    * [Point values](#Pointvalues)\n        * [Parameters](#Parameters)\n        * [Output](#Output)\n    * [Ranges](#Ranges)\n        * [Parameters](#Parameters-1)\n        * [Output](#Output-1)\n* [Redis data structure](#Redisdatastructure)\n    * [Timeseries](#Timeseries)\n    * [Hashes](#Hashes)\n    * [Sorted sets](#Sortedsets)\n* [Cron](#Cron)\n\n\u003c!-- vscode-markdown-toc-config\n    numbering=false\n    autoSave=true\n    /vscode-markdown-toc-config --\u003e\n\u003c!-- /vscode-markdown-toc --\u003e\n\n## \u003ca name='Introduction'\u003e\u003c/a\u003eIntroduction\n\nThis package implements API endpoints for package download counts similar to [the ones](https://github.com/npm/registry/blob/master/docs/download-counts.md) provided by npm, but limited to a specific package.\n\nThe stats data is stored in Redis, using [RedisTimeSeries](https://redis.io/docs/stack/timeseries/). Please refer to the [Redis data structure](#redis-data-structure) section for more information.\n\nNote that this package does not include a widget for the Verdaccio web UI.\n\n## \u003ca name='Install'\u003e\u003c/a\u003eInstall\n\nInstall the package.\n```\nnpm install verdaccio-install-counts\n```\n\nUpdate the `middlewares` seciton of verdaccio's `config.yaml`.\n```\nmiddlewares:\n  install-counts:\n    enabled: true\n    redis:\n      host: 127.0.0.1\n      port: 6379\n      password: ...\n```\n\n## \u003ca name='APIendpoints'\u003e\u003c/a\u003eAPI endpoints\n\n### \u003ca name='Pointvalues'\u003e\u003c/a\u003ePoint values\n\nGets the total downloads for a given period for a specific package.\n\n```\nGET https://127.0.0.1:4873/downloads/point/{period}/{package}\n```\n\n#### \u003ca name='Parameters'\u003e\u003c/a\u003eParameters\n\nAcceptable values for `period` for a specific package. The timezone is GMT.\n\n\u003cdl\u003e\n    \u003cdt\u003eall-time\u003c/dt\u003e\n    \u003cdd\u003eGets total downloads.\u003c/dd\u003e\n    \u003cdt\u003elast-day\u003c/dt\u003e\n    \u003cdd\u003eGets downloads for the last available day.\u003c/dd\u003e\n    \u003cdt\u003elast-week\u003c/dt\u003e\n    \u003cdd\u003eGets downloads for the last 7 available days.\u003c/dd\u003e\n    \u003cdt\u003elast-month\u003c/dt\u003e\n    \u003cdd\u003eGets downloads for the last 30 available days.\u003c/dd\u003e\n    \u003cdt\u003e{start_date}:{end_date}\u003c/dt\u003e\n    \u003cdd\u003eGets downloads for a given date range. The date format is yyyy-mm-dd.\u003c/dd\u003e\n\u003c/dl\u003e\n\n#### \u003ca name='Output'\u003e\u003c/a\u003eOutput\n\nJSON output:\n\n```javascript\n{\n  \"downloads\": 16230,\n  \"start\": \"2023-01-01\",\n  \"end\": \"2023-01-31\",\n  \"package\": \"com.example.package\"\n}\n```\n\n### \u003ca name='Ranges'\u003e\u003c/a\u003eRanges\n\nGets the downloads per day for a given period for a specific package.\n\n```\nGET https://127.0.0.1:4873/downloads/range/{period}/{package}\n```\n\n#### \u003ca name='Parameters-1'\u003e\u003c/a\u003eParameters\n\nSame as for `/downloads/point`.\n\n#### \u003ca name='Output-1'\u003e\u003c/a\u003eOutput\n\nResponses are very similar to the point API, except that downloads is now an array of days with downloads on each day:\n\n```javascript\n{\n    \"downloads\": [\n        {\n            \"day\": \"2023-01-01\",\n            \"downloads\": 540\n        },\n        ..\n        {\n            \"day\": \"2023-01-31\",\n            \"downloads\": 425\n        }\n    ],\n    \"start\": \"2023-01-01\",\n    \"end\": \"2023-01-31\",\n    \"package\": \"com.example.package\"\n}\n```\n\n## \u003ca name='Redisdatastructure'\u003e\u003c/a\u003eRedis data structure\n\nThe stats data is stored in Redis using timeseries, hashes or sorted sets.\n\n### \u003ca name='Timeseries'\u003e\u003c/a\u003eTimeseries\n\nTimeseries for daily download counts for a specific package.\n```\ntspkghit:daily:\u003cpackage_name\u003e \u003ctimestamp_utc\u003e \u003ccount\u003e LABELS category tspkghit:daily pkgname \u003cpackage_name\u003e\n```\n\n### \u003ca name='Hashes'\u003e\u003c/a\u003eHashes\n\nHash for download counts for a specific package breakdown by versions.\n```\npkghit:ver:\u003cpackage_name\u003e \u003cversion\u003e \u003ccount\u003e\n```\n\n### \u003ca name='Sortedsets'\u003e\u003c/a\u003eSorted sets\n\nSorted set for all-time download counts.\n```\nzpkghit:alltime \u003ccount\u003e \u003cpackage_name\u003e\n```\n\nSorted set for the last 30 days' download counts.\n```\nzpkghit:lastmonth \u003ccount\u003e \u003cpackage_name\u003e \n```\n\n## \u003ca name='Cron'\u003e\u003c/a\u003eCron\n\nThe `zpkghit:lastmonth` sorted set requries a cron job:\n```bash\nVERDACCIO_CONFIG=config.yaml npm run update-lastmonth\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenupm%2Fverdaccio-install-counts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenupm%2Fverdaccio-install-counts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenupm%2Fverdaccio-install-counts/lists"}