首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >通过github api统计组织Star数

通过github api统计组织Star数

作者头像
阿超
发布于 2024-08-23 19:57:46
发布于 2024-08-23 19:57:46
6150
举报
文章被收录于专栏:快乐阿超快乐阿超

君子之学,博于外而尤贵精于内。——王廷相

文档如下:

https://docs.github.com/zh/rest/orgs/orgs?apiVersion=2022-11-28

代码如下:

代码语言:javascript
复制
const response = await fetch('https://api.github.com/orgs/dromara/repos?per_page=100&page=1');
  if (!response.ok) {
    throw new Error(`Error fetching repos: ${response.statusText}`);
  }
  const repos = await response.json();
console.log(repos)
const list = repos.map(({name,stargazers_count})=>({name,stargazers_count}))
console.log(list)
list.reduce(
  (accumulator, currentValue) => accumulator + currentValue.stargazers_count,
  0,
);

注意这里是分页,我们把每一页的结果相加,得到github上dromara的82个仓库拥有89972个star

apache则非常之多,2659个仓库1122875个star

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2024-08-15,如有侵权请联系 cloudcommunity@tencent.com 删除
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档