GitHub API:获取结算配额重置日期

3

我可以使用GitHub API来检索在GitHub Actions中,还有多少天 X 个配额将被重置。该信息可以在https://github.com/settings/billing页面找到。

billing quota

要执行此操作,您需要调用以下API:

# GITHUB_TOKEN with "Update ALL user data" permission
curl \
  -H "Authorization: token $GITHUB_TOKEN" \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/users/$GITHUB_USER/settings/billing/actions

我可以获取除账期到期日期之外的所有信息:

{
  "total_minutes_used": 228,
  "total_paid_minutes_used": 0,
  "included_minutes": 2000,
  "minutes_used_breakdown": {
    "UBUNTU": 228
  }
}

非常感谢。

在不久的将来,https://github.com/github/roadmap/issues/246 会有所帮助吗? - VonC
1个回答

2

我已经找到了从/users/<user>/settings/billing/shared-storage端点获取“账单周期剩余天数”的方法。

例如:

curl \
  -H "Authorization: token $GITHUB_TOKEN" \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/users/$GITHUB_USER/settings/billing/shared-storage

返回值

{
  "days_left_in_billing_cycle": 5,
  "estimated_paid_storage_for_month": 0,
  "estimated_storage_for_month": 0
}

2
这是一个检索有关用户账单的所有数据的脚本:https://gist.github.com/horothesun/cb799c61a983a17c4aff68d9d413c4bf - horothesun

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接