by shigemk2

当面は技術的なことしか書かない

homebrewのAPIで遊んでみよう

homebrewのAPIで遊んでみよう

各Formulaの情報とか、統計情報(おそらくGAでデータを集めていると思われる)からインストール数や過去N日間におけるインストール数のランキングとかが取れる。

Formulaの情報

$ curl -XGET "https://formulae.brew.sh/api/formula/digdag.json"
{"name":"digdag","full_name":"digdag","oldname":null,"aliases":[],"versioned_formulae":[],"desc":"Workload Automation System","homepage":"https://www.digdag.io/","versions":{"stable":"0.9.39","devel":null,"head":null,"bottle":false},"revision":0,"version_scheme":0,"bottle":{},"keg_only":false,"bottle_disabled":true,"options":[],"build_dependencies":[],"dependencies":[],"recommended_dependencies":[],"optional_dependencies":[],"uses_from_macos":[],"requirements":[{"name":"java","cask":"adoptopenjdk","download":null}],"conflicts_with":[],"caveats":null,"installed":[],"linked_keg":null,"pinned":false,"outdated":false,"analytics":{"install":{"30d":{"digdag":92},"90d":{"digdag":349},"365d":{"digdag":1614}},"install_on_request":{"30d":{"digdag":91},"90d":{"digdag":346},"365d":{"digdag":1572}},"build_error":{"30d":{"digdag":0}}}}

直近30日間のインストール数ランキング

$ curl -XGET "https://formulae.brew.sh/api/analytics/install/30d.json" | jq -r '.items[] | "\(.formula)\t\(.count)" ' | head -10
openssl@1.1   702,597
readline    529,419
python  490,310
sqlite  358,578
node    342,575
glib    326,196
gettext 290,312
icu4c   238,522
gdbm    237,651

Formula別 直近30日間のインストール数

$ curl -XGET "https://formulae.brew.sh/api/analytics/install/30d.json" | jq -r '.items[] | try select(.formula == "presto")' | head
{
  "number": 1508,
  "formula": "presto",
  "count": "331",
  "percent": "0.00"
}
$ curl -XGET "https://formulae.brew.sh/api/analytics/install/30d.json" | jq -r '.items[] | try select(.formula == "awscli")' | head
{
  "number": 61,
  "formula": "awscli",
  "count": "72,948",
  "percent": "0.40"
}
$ curl -XGET "https://formulae.brew.sh/api/analytics/install/30d.json" | jq -r '.items[] | try select(.formula == "vim")' | head
{
  "number": 68,
  "formula": "vim",
  "count": "66,826",
  "percent": "0.36"
}