Skip to content

Instantly share code, notes, and snippets.

@dmitmel
Last active November 3, 2018 15:32
Show Gist options
  • Save dmitmel/22e0eb882443756ec8d13831d0c0b596 to your computer and use it in GitHub Desktop.
Save dmitmel/22e0eb882443756ec8d13831d0c0b596 to your computer and use it in GitHub Desktop.
number of NPM packages vs every other language
import datetime
import requests
api = "http://www.modulecounts.com"
def api_call(endpoint, *args, **kwargs):
url = api + endpoint.format(*args, **kwargs)
return requests.get(url).json()
today = datetime.date.today()
today_str = today.strftime("%Y-%m-%d")
print("data for", today_str)
print()
repositories = api_call("/repositories")
data = {}
for repo in repositories:
repo_name = repo["name"]
repo_id = repo["id"]
repo_counts = api_call(
"/repositories/{id}/counts/{date}/{date}", id=repo_id, date=today_str
)
if len(repo_counts) > 0:
modules_count = repo_counts[0]["value"]
print(repo_name, modules_count)
data[repo_name] = modules_count
print()
print("npm", data["npm (node.js)"])
print(
"other",
sum(
[
modules_count
for name, modules_count in data.items()
if name != "npm (node.js)"
]
),
)
Clojars (Clojure) 22897
CPAN 39114
CRAN (R) 13328
Crates.io (Rust) 19921
Crystal Shards 3863
Drupal (php) 41798
DUB (dlang) 1435
Gopm (go) 21124
Hackage (Haskell) 13218
Hex.pm (Elixir/Erlang) 7205
Julia 1906
Maven Central (Java) 254710
MELPA (Emacs) 3981
Nimble (Nim) 813
npm (node.js) 720290
nuget (.NET) 132150
Packagist (PHP) 200980
Pear (PHP) 602
Perl 6 Ecosystem (perl 6) 1248
PyPI 157199
Rubygems.org 147575
Vim Scripts 5536
npm 720290
other 1090603
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment