GitHub Marketplace 的 REST API 终结点
使用 REST API 与 GitHub Marketplace 交互
关于 GitHub Marketplace
有关 GitHub Marketplace 的详细信息,请参阅“GitHub 市场”。
可以通过这些终结点查看哪些客户正在使用定价计划、客户的购买情况,以及帐户是否具有有效订阅。
使用存根端点进行测试
可以使用存根数据测试 GitHub App。 存根数据是硬编码的假数据,不会根据实际订阅而更改。
要使用存根数据进行测试,请使用存根端点代替其对应的生产端点。 这允许你在 GitHub Marketplace 上列出 GitHub Apps 之前测试 API 逻辑是否成功。
在部署 GitHub App 之前,确保将存根终结点替换为生产终结点。
Get a subscription plan for an account
Shows whether the user or organization account actively subscribes to a plan listed by the authenticated GitHub App. When someone submits a plan change that won't be processed until the end of their billing cycle, you will also see the upcoming pending change.
GitHub Apps must use a JWT to access this endpoint. OAuth apps must use basic authentication with their client ID and client secret to access this endpoint.
“Get a subscription plan for an account”的细粒度访问令牌
此终结点不适用于 GitHub 应用程序用户访问令牌、GitHub 应用程序安装访问令牌或细粒度个人访问令牌。
“Get a subscription plan for an account”的参数
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
account_id integer 必须account_id parameter |
“Get a subscription plan for an account”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
200 | OK |
401 | Requires authentication |
404 | Not Found when the account has not purchased the listing |
“Get a subscription plan for an account”的示例代码
If you access GitHub at GHE.com, replace api.github.com
with your enterprise's dedicated subdomain at api.SUBDOMAIN.ghe.com
.
请求示例
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/marketplace_listing/accounts/ACCOUNT_ID
Response
Status: 200
{
"url": "https://api.github.com/orgs/github",
"type": "Organization",
"id": 4,
"login": "github",
"organization_billing_email": "billing@github.com",
"email": "billing@github.com",
"marketplace_pending_change": {
"effective_date": "2017-11-11T00:00:00Z",
"unit_count": null,
"id": 77,
"plan": {
"url": "https://api.github.com/marketplace_listing/plans/1111",
"accounts_url": "https://api.github.com/marketplace_listing/plans/1111/accounts",
"id": 1111,
"number": 2,
"name": "Startup",
"description": "A professional-grade CI solution",
"monthly_price_in_cents": 699,
"yearly_price_in_cents": 7870,
"price_model": "FLAT_RATE",
"has_free_trial": true,
"state": "published",
"unit_name": null,
"bullets": [
"Up to 10 private repositories",
"3 concurrent builds"
]
}
},
"marketplace_purchase": {
"billing_cycle": "monthly",
"next_billing_date": "2017-11-11T00:00:00Z",
"unit_count": null,
"on_free_trial": true,
"free_trial_ends_on": "2017-11-11T00:00:00Z",
"updated_at": "2017-11-02T01:12:12Z",
"plan": {
"url": "https://api.github.com/marketplace_listing/plans/1313",
"accounts_url": "https://api.github.com/marketplace_listing/plans/1313/accounts",
"id": 1313,
"number": 3,
"name": "Pro",
"description": "A professional-grade CI solution",
"monthly_price_in_cents": 1099,
"yearly_price_in_cents": 11870,
"price_model": "FLAT_RATE",
"has_free_trial": true,
"unit_name": null,
"state": "published",
"bullets": [
"Up to 25 private repositories",
"11 concurrent builds"
]
}
}
}
List plans
Lists all plans that are part of your GitHub Enterprise Cloud Marketplace listing.
GitHub Apps must use a JWT to access this endpoint. OAuth apps must use basic authentication with their client ID and client secret to access this endpoint.
“List plans”的细粒度访问令牌
此终结点不适用于 GitHub 应用程序用户访问令牌、GitHub 应用程序安装访问令牌或细粒度个人访问令牌。
“List plans”的参数
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." 默认: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." 默认: |
“List plans”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
200 | OK |
401 | Requires authentication |
404 | Resource not found |
“List plans”的示例代码
If you access GitHub at GHE.com, replace api.github.com
with your enterprise's dedicated subdomain at api.SUBDOMAIN.ghe.com
.
请求示例
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/marketplace_listing/plans
Response
Status: 200
[
{
"url": "https://api.github.com/marketplace_listing/plans/1313",
"accounts_url": "https://api.github.com/marketplace_listing/plans/1313/accounts",
"id": 1313,
"number": 3,
"name": "Pro",
"description": "A professional-grade CI solution",
"monthly_price_in_cents": 1099,
"yearly_price_in_cents": 11870,
"price_model": "FLAT_RATE",
"has_free_trial": true,
"unit_name": null,
"state": "published",
"bullets": [
"Up to 25 private repositories",
"11 concurrent builds"
]
}
]
List accounts for a plan
Returns user and organization accounts associated with the specified plan, including free plans. For per-seat pricing, you see the list of accounts that have purchased the plan, including the number of seats purchased. When someone submits a plan change that won't be processed until the end of their billing cycle, you will also see the upcoming pending change.
GitHub Apps must use a JWT to access this endpoint. OAuth apps must use basic authentication with their client ID and client secret to access this endpoint.
“List accounts for a plan”的细粒度访问令牌
此终结点不适用于 GitHub 应用程序用户访问令牌、GitHub 应用程序安装访问令牌或细粒度个人访问令牌。
“List accounts for a plan”的参数
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
plan_id integer 必须The unique identifier of the plan. |
名称, 类型, 说明 |
---|
sort string The property to sort the results by. 默认: 可以是以下选项之一: |
direction string To return the oldest accounts first, set to 可以是以下选项之一: |
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." 默认: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." 默认: |
“List accounts for a plan”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
200 | OK |
401 | Requires authentication |
404 | Resource not found |
422 | Validation failed, or the endpoint has been spammed. |
“List accounts for a plan”的示例代码
If you access GitHub at GHE.com, replace api.github.com
with your enterprise's dedicated subdomain at api.SUBDOMAIN.ghe.com
.
请求示例
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/marketplace_listing/plans/PLAN_ID/accounts
Response
Status: 200
[
{
"url": "https://api.github.com/orgs/github",
"type": "Organization",
"id": 4,
"login": "github",
"organization_billing_email": "billing@github.com",
"marketplace_pending_change": {
"effective_date": "2017-11-11T00:00:00Z",
"unit_count": null,
"id": 77,
"plan": {
"url": "https://api.github.com/marketplace_listing/plans/1111",
"accounts_url": "https://api.github.com/marketplace_listing/plans/1111/accounts",
"id": 1111,
"number": 2,
"name": "Startup",
"description": "A professional-grade CI solution",
"monthly_price_in_cents": 699,
"yearly_price_in_cents": 7870,
"price_model": "FLAT_RATE",
"has_free_trial": true,
"state": "published",
"unit_name": null,
"bullets": [
"Up to 10 private repositories",
"3 concurrent builds"
]
}
},
"marketplace_purchase": {
"billing_cycle": "monthly",
"next_billing_date": "2017-11-11T00:00:00Z",
"unit_count": null,
"on_free_trial": true,
"free_trial_ends_on": "2017-11-11T00:00:00Z",
"updated_at": "2017-11-02T01:12:12Z",
"plan": {
"url": "https://api.github.com/marketplace_listing/plans/1313",
"accounts_url": "https://api.github.com/marketplace_listing/plans/1313/accounts",
"id": 1313,
"number": 3,
"name": "Pro",
"description": "A professional-grade CI solution",
"monthly_price_in_cents": 1099,
"yearly_price_in_cents": 11870,
"price_model": "FLAT_RATE",
"has_free_trial": true,
"unit_name": null,
"state": "published",
"bullets": [
"Up to 25 private repositories",
"11 concurrent builds"
]
}
}
}
]
Get a subscription plan for an account (stubbed)
Shows whether the user or organization account actively subscribes to a plan listed by the authenticated GitHub App. When someone submits a plan change that won't be processed until the end of their billing cycle, you will also see the upcoming pending change.
GitHub Apps must use a JWT to access this endpoint. OAuth apps must use basic authentication with their client ID and client secret to access this endpoint.
“Get a subscription plan for an account (stubbed)”的细粒度访问令牌
此终结点不适用于 GitHub 应用程序用户访问令牌、GitHub 应用程序安装访问令牌或细粒度个人访问令牌。
“Get a subscription plan for an account (stubbed)”的参数
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
account_id integer 必须account_id parameter |
“Get a subscription plan for an account (stubbed)”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
200 | OK |
401 | Requires authentication |
404 | Not Found when the account has not purchased the listing |
“Get a subscription plan for an account (stubbed)”的示例代码
If you access GitHub at GHE.com, replace api.github.com
with your enterprise's dedicated subdomain at api.SUBDOMAIN.ghe.com
.
请求示例
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/marketplace_listing/stubbed/accounts/ACCOUNT_ID
Response
Status: 200
{
"url": "https://api.github.com/orgs/github",
"type": "Organization",
"id": 4,
"login": "github",
"organization_billing_email": "billing@github.com",
"email": "billing@github.com",
"marketplace_pending_change": {
"effective_date": "2017-11-11T00:00:00Z",
"unit_count": null,
"id": 77,
"plan": {
"url": "https://api.github.com/marketplace_listing/plans/1111",
"accounts_url": "https://api.github.com/marketplace_listing/plans/1111/accounts",
"id": 1111,
"number": 2,
"name": "Startup",
"description": "A professional-grade CI solution",
"monthly_price_in_cents": 699,
"yearly_price_in_cents": 7870,
"price_model": "FLAT_RATE",
"has_free_trial": true,
"state": "published",
"unit_name": null,
"bullets": [
"Up to 10 private repositories",
"3 concurrent builds"
]
}
},
"marketplace_purchase": {
"billing_cycle": "monthly",
"next_billing_date": "2017-11-11T00:00:00Z",
"unit_count": null,
"on_free_trial": true,
"free_trial_ends_on": "2017-11-11T00:00:00Z",
"updated_at": "2017-11-02T01:12:12Z",
"plan": {
"url": "https://api.github.com/marketplace_listing/plans/1313",
"accounts_url": "https://api.github.com/marketplace_listing/plans/1313/accounts",
"id": 1313,
"number": 3,
"name": "Pro",
"description": "A professional-grade CI solution",
"monthly_price_in_cents": 1099,
"yearly_price_in_cents": 11870,
"price_model": "FLAT_RATE",
"has_free_trial": true,
"unit_name": null,
"state": "published",
"bullets": [
"Up to 25 private repositories",
"11 concurrent builds"
]
}
}
}
List plans (stubbed)
Lists all plans that are part of your GitHub Enterprise Cloud Marketplace listing.
GitHub Apps must use a JWT to access this endpoint. OAuth apps must use basic authentication with their client ID and client secret to access this endpoint.
“List plans (stubbed)”的细粒度访问令牌
此终结点不适用于 GitHub 应用程序用户访问令牌、GitHub 应用程序安装访问令牌或细粒度个人访问令牌。
“List plans (stubbed)”的参数
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." 默认: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." 默认: |
“List plans (stubbed)”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
200 | OK |
401 | Requires authentication |
“List plans (stubbed)”的示例代码
If you access GitHub at GHE.com, replace api.github.com
with your enterprise's dedicated subdomain at api.SUBDOMAIN.ghe.com
.
请求示例
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/marketplace_listing/stubbed/plans
Response
Status: 200
[
{
"url": "https://api.github.com/marketplace_listing/plans/1313",
"accounts_url": "https://api.github.com/marketplace_listing/plans/1313/accounts",
"id": 1313,
"number": 3,
"name": "Pro",
"description": "A professional-grade CI solution",
"monthly_price_in_cents": 1099,
"yearly_price_in_cents": 11870,
"price_model": "FLAT_RATE",
"has_free_trial": true,
"unit_name": null,
"state": "published",
"bullets": [
"Up to 25 private repositories",
"11 concurrent builds"
]
}
]
List accounts for a plan (stubbed)
Returns repository and organization accounts associated with the specified plan, including free plans. For per-seat pricing, you see the list of accounts that have purchased the plan, including the number of seats purchased. When someone submits a plan change that won't be processed until the end of their billing cycle, you will also see the upcoming pending change.
GitHub Apps must use a JWT to access this endpoint. OAuth apps must use basic authentication with their client ID and client secret to access this endpoint.
“List accounts for a plan (stubbed)”的细粒度访问令牌
此终结点不适用于 GitHub 应用程序用户访问令牌、GitHub 应用程序安装访问令牌或细粒度个人访问令牌。
“List accounts for a plan (stubbed)”的参数
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
plan_id integer 必须The unique identifier of the plan. |
名称, 类型, 说明 |
---|
sort string The property to sort the results by. 默认: 可以是以下选项之一: |
direction string To return the oldest accounts first, set to 可以是以下选项之一: |
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." 默认: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." 默认: |
“List accounts for a plan (stubbed)”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
200 | OK |
401 | Requires authentication |
“List accounts for a plan (stubbed)”的示例代码
If you access GitHub at GHE.com, replace api.github.com
with your enterprise's dedicated subdomain at api.SUBDOMAIN.ghe.com
.
请求示例
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/marketplace_listing/stubbed/plans/PLAN_ID/accounts
Response
Status: 200
[
{
"url": "https://api.github.com/orgs/github",
"type": "Organization",
"id": 4,
"login": "github",
"organization_billing_email": "billing@github.com",
"marketplace_pending_change": {
"effective_date": "2017-11-11T00:00:00Z",
"unit_count": null,
"id": 77,
"plan": {
"url": "https://api.github.com/marketplace_listing/plans/1111",
"accounts_url": "https://api.github.com/marketplace_listing/plans/1111/accounts",
"id": 1111,
"number": 2,
"name": "Startup",
"description": "A professional-grade CI solution",
"monthly_price_in_cents": 699,
"yearly_price_in_cents": 7870,
"price_model": "FLAT_RATE",
"has_free_trial": true,
"state": "published",
"unit_name": null,
"bullets": [
"Up to 10 private repositories",
"3 concurrent builds"
]
}
},
"marketplace_purchase": {
"billing_cycle": "monthly",
"next_billing_date": "2017-11-11T00:00:00Z",
"unit_count": null,
"on_free_trial": true,
"free_trial_ends_on": "2017-11-11T00:00:00Z",
"updated_at": "2017-11-02T01:12:12Z",
"plan": {
"url": "https://api.github.com/marketplace_listing/plans/1313",
"accounts_url": "https://api.github.com/marketplace_listing/plans/1313/accounts",
"id": 1313,
"number": 3,
"name": "Pro",
"description": "A professional-grade CI solution",
"monthly_price_in_cents": 1099,
"yearly_price_in_cents": 11870,
"price_model": "FLAT_RATE",
"has_free_trial": true,
"unit_name": null,
"state": "published",
"bullets": [
"Up to 25 private repositories",
"11 concurrent builds"
]
}
}
}
]
List subscriptions for the authenticated user
Lists the active subscriptions for the authenticated user.
“List subscriptions for the authenticated user”的细粒度访问令牌
此端点支持以下精细令牌类型:
精细令牌不需要任何权限。
“List subscriptions for the authenticated user”的参数
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." 默认: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." 默认: |
“List subscriptions for the authenticated user”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
200 | OK |
304 | Not modified |
401 | Requires authentication |
404 | Resource not found |
“List subscriptions for the authenticated user”的示例代码
If you access GitHub at GHE.com, replace api.github.com
with your enterprise's dedicated subdomain at api.SUBDOMAIN.ghe.com
.
请求示例
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/user/marketplace_purchases
Response
Status: 200
[
{
"billing_cycle": "monthly",
"next_billing_date": "2017-11-11T00:00:00Z",
"unit_count": null,
"on_free_trial": true,
"free_trial_ends_on": "2017-11-11T00:00:00Z",
"updated_at": "2017-11-02T01:12:12Z",
"account": {
"login": "github",
"id": 4,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE=",
"url": "https://api.github.com/orgs/github",
"email": null,
"organization_billing_email": "billing@github.com",
"type": "Organization"
},
"plan": {
"url": "https://api.github.com/marketplace_listing/plans/1313",
"accounts_url": "https://api.github.com/marketplace_listing/plans/1313/accounts",
"id": 1313,
"number": 3,
"name": "Pro",
"description": "A professional-grade CI solution",
"monthly_price_in_cents": 1099,
"yearly_price_in_cents": 11870,
"price_model": "FLAT_RATE",
"has_free_trial": true,
"unit_name": null,
"state": "published",
"bullets": [
"Up to 25 private repositories",
"11 concurrent builds"
]
}
}
]
List subscriptions for the authenticated user (stubbed)
Lists the active subscriptions for the authenticated user.
“List subscriptions for the authenticated user (stubbed)”的细粒度访问令牌
此端点支持以下精细令牌类型:
精细令牌不需要任何权限。
“List subscriptions for the authenticated user (stubbed)”的参数
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." 默认: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." 默认: |
“List subscriptions for the authenticated user (stubbed)”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
200 | OK |
304 | Not modified |
401 | Requires authentication |
“List subscriptions for the authenticated user (stubbed)”的示例代码
If you access GitHub at GHE.com, replace api.github.com
with your enterprise's dedicated subdomain at api.SUBDOMAIN.ghe.com
.
请求示例
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/user/marketplace_purchases/stubbed
Response
Status: 200
[
{
"billing_cycle": "monthly",
"next_billing_date": "2017-11-11T00:00:00Z",
"unit_count": null,
"on_free_trial": true,
"free_trial_ends_on": "2017-11-11T00:00:00Z",
"updated_at": "2017-11-02T01:12:12Z",
"account": {
"login": "github",
"id": 4,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE=",
"url": "https://api.github.com/orgs/github",
"email": null,
"organization_billing_email": "billing@github.com",
"type": "Organization"
},
"plan": {
"url": "https://api.github.com/marketplace_listing/plans/1313",
"accounts_url": "https://api.github.com/marketplace_listing/plans/1313/accounts",
"id": 1313,
"number": 3,
"name": "Pro",
"description": "A professional-grade CI solution",
"monthly_price_in_cents": 1099,
"yearly_price_in_cents": 11870,
"price_model": "FLAT_RATE",
"has_free_trial": true,
"unit_name": null,
"state": "published",
"bullets": [
"Up to 25 private repositories",
"11 concurrent builds"
]
}
}
]