Skip to main content
The REST API is now versioned. For more information, see "About API versioning."

GitHub 市场

使用 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.

Parameters for "Get a subscription plan for an account"

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
account_id integer 必须

account_id parameter

HTTP response status codes for "Get a subscription plan for an account"

Status codeDescription
200

OK

401

Requires authentication

404

Not Found when the account has not purchased the listing

Code samples for "Get a subscription plan for an account"

get/marketplace_listing/accounts/{account_id}
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 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.

Parameters for "List plans"

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

查询参数
名称, 类型, 说明
per_page integer

The number of results per page (max 100).

默认: 30

page integer

Page number of the results to fetch.

默认: 1

HTTP response status codes for "List plans"

Status codeDescription
200

OK

401

Requires authentication

404

Resource not found

Code samples for "List plans"

get/marketplace_listing/plans
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.

Parameters for "List accounts for a plan"

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
plan_id integer 必须

The unique identifier of the plan.

查询参数
名称, 类型, 说明
sort string

The property to sort the results by.

默认: created

可以是以下选项之一: created, updated

direction string

To return the oldest accounts first, set to asc. Ignored without the sort parameter.

可以是以下选项之一: asc, desc

per_page integer

The number of results per page (max 100).

默认: 30

page integer

Page number of the results to fetch.

默认: 1

HTTP response status codes for "List accounts for a plan"

Status codeDescription
200

OK

401

Requires authentication

404

Resource not found

422

Validation failed, or the endpoint has been spammed.

Code samples for "List accounts for a plan"

get/marketplace_listing/plans/{plan_id}/accounts
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.

Parameters for "Get a subscription plan for an account (stubbed)"

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
account_id integer 必须

account_id parameter

HTTP response status codes for "Get a subscription plan for an account (stubbed)"

Status codeDescription
200

OK

401

Requires authentication

404

Not Found when the account has not purchased the listing

Code samples for "Get a subscription plan for an account (stubbed)"

get/marketplace_listing/stubbed/accounts/{account_id}
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 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.

Parameters for "List plans (stubbed)"

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

查询参数
名称, 类型, 说明
per_page integer

The number of results per page (max 100).

默认: 30

page integer

Page number of the results to fetch.

默认: 1

HTTP response status codes for "List plans (stubbed)"

Status codeDescription
200

OK

401

Requires authentication

Code samples for "List plans (stubbed)"

get/marketplace_listing/stubbed/plans
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.

Parameters for "List accounts for a plan (stubbed)"

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
plan_id integer 必须

The unique identifier of the plan.

查询参数
名称, 类型, 说明
sort string

The property to sort the results by.

默认: created

可以是以下选项之一: created, updated

direction string

To return the oldest accounts first, set to asc. Ignored without the sort parameter.

可以是以下选项之一: asc, desc

per_page integer

The number of results per page (max 100).

默认: 30

page integer

Page number of the results to fetch.

默认: 1

HTTP response status codes for "List accounts for a plan (stubbed)"

Status codeDescription
200

OK

401

Requires authentication

Code samples for "List accounts for a plan (stubbed)"

get/marketplace_listing/stubbed/plans/{plan_id}/accounts
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. GitHub Apps must use a user access token, created for a user who has authorized your GitHub App, to access this endpoint. OAuth apps must authenticate using an OAuth token.

Parameters for "List subscriptions for the authenticated user"

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

查询参数
名称, 类型, 说明
per_page integer

The number of results per page (max 100).

默认: 30

page integer

Page number of the results to fetch.

默认: 1

HTTP response status codes for "List subscriptions for the authenticated user"

Status codeDescription
200

OK

304

Not modified

401

Requires authentication

404

Resource not found

Code samples for "List subscriptions for the authenticated user"

get/user/marketplace_purchases
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. GitHub Apps must use a user access token, created for a user who has authorized your GitHub App, to access this endpoint. OAuth apps must authenticate using an OAuth token.

Parameters for "List subscriptions for the authenticated user (stubbed)"

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

查询参数
名称, 类型, 说明
per_page integer

The number of results per page (max 100).

默认: 30

page integer

Page number of the results to fetch.

默认: 1

HTTP response status codes for "List subscriptions for the authenticated user (stubbed)"

Status codeDescription
200

OK

304

Not modified

401

Requires authentication

Code samples for "List subscriptions for the authenticated user (stubbed)"

get/user/marketplace_purchases/stubbed
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" ] } } ]