# ライセンス用 REST API エンドポイント

REST API を使用して、一般的なopen source ライセンスと、特定のプロジェクトのライセンス ファイルに関する情報を取得します。

## ライセンスについて

GitHub は、[ Ruby Gem Licensee](https://github.com/benbalter/licensee) open sourceを使用して、プロジェクトのライセンスの識別を試みます。 ライセンシーは、プロジェクトの `LICENSE` ファイル (存在する場合) を既知のライセンスの短いリストと照合します。 そのためライセンス API では、プロジェクト依存関係のライセンス、あるいはプロジェクトのライセンスをドキュメント化するその他の方法、たとえばドキュメントにおけるライセンス名の参照などは考慮されません。

ライセンスが一致した場合、返されたライセンスキーと名前は [SPDX 仕様](https://spdx.org/)に準拠します。

**注釈:** 以下のエンドポイントも、リポジトリのライセンス情報を返します。

* [リポジトリの取得](/ja/enterprise-server@3.21/rest/repos/repos#get-a-repository)
* [ユーザーのリポジトリの一覧表示](/ja/enterprise-server@3.21/rest/repos/repos#list-repositories-for-a-user)
* [組織リポジトリの一覧表示](/ja/enterprise-server@3.21/rest/repos/repos#list-organization-repositories)
* [フォークの一覧表示](/ja/enterprise-server@3.21/rest/repos/forks#list-forks)
* [ユーザーがウォッチしているリポジトリの一覧表示](/ja/enterprise-server@3.21/rest/activity/watching#list-repositories-watched-by-a-user)
* [チーム リポジトリの一覧表示](/ja/enterprise-server@3.21/rest/teams/teams#list-team-repositories)

> \[!WARNING]
> GitHubは多くのものですが、法律事務所ではありません。 そのため、GitHub は、法的助言を行っていません。 API を使ったり、それについてのメールを当社へ送信したりすることは、法的助言には該当せず、弁護士と依頼人の関係を確立するものでもありません。 特定のライセンスで許可される範囲について疑問がある場合は、先に進む前にそれぞれの顧問弁護士にご相談ください。 むしろ、法的な結果が想定される、あるいは法律上の権利に影響しうる決定を下す場合には、必ずその前に各自の弁護士にご相談ください。
>
> GitHub は、ユーザーがライセンスopen sourceおよびそれらを使用するプロジェクトに関する情報を取得できるように、これらのエンドポイントを作成しました。 お役に立てれば幸いですが、当社は (少なくとも従業員のほとんどは) 弁護士ではなく、他の方と同じように誤りがないとは言えません。 そのため、GitHub は、API を「現状のまま」提供しており、その API で、またはその API 経由で提供される情報またはライセンスに関する情報について一切保証せず、その API の使用に起因する損害についての責任も負いません。

> \[!NOTE]
> Most endpoints use `Authorization: Bearer <YOUR-TOKEN>` and `Accept: application/vnd.github+json` headers, plus `X-GitHub-Api-Version: 2026-03-10`. Curl examples below omit these standard headers for brevity.

## Get all commonly used licenses

```
GET /licenses
```

Lists the most commonly used licenses on GitHub. For more information, see "Licensing a repository ."

### Parameters

#### Headers

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`featured`** (boolean)

* **`per_page`** (integer)
  The number of results per page (max 100). For more information, see "Using pagination in the REST API."
  Default: `30`

* **`page`** (integer)
  The page number of the results to fetch. For more information, see "Using pagination in the REST API."
  Default: `1`

### HTTP response status codes

* **200** - OK

* **304** - Not modified

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X GET \
  http(s)://HOSTNAME/api/v3/licenses
```

**Response schema (Status: 200):**

Array of `License Simple`:

* `key`: required, string
* `name`: required, string
* `url`: required, string or null, format: uri
* `spdx_id`: required, string or null
* `node_id`: required, string
* `html_url`: string, format: uri

## Get a license

```
GET /licenses/{license}
```

Gets information about a specific license. For more information, see "Licensing a repository ."

### Parameters

#### Headers

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`license`** (string) (required)

### HTTP response status codes

* **200** - OK

* **304** - Not modified

* **403** - Forbidden

* **404** - Resource not found

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X GET \
  http(s)://HOSTNAME/api/v3/licenses/LICENSE
```

**Response schema (Status: 200):**

* `key`: required, string
* `name`: required, string
* `spdx_id`: required, string or null
* `url`: required, string or null, format: uri
* `node_id`: required, string
* `html_url`: required, string, format: uri
* `description`: required, string
* `implementation`: required, string
* `permissions`: required, array of string
* `conditions`: required, array of string
* `limitations`: required, array of string
* `body`: required, string
* `featured`: required, boolean

## Get the license for a repository

```
GET /repos/{owner}/{repo}/license
```

This method returns the contents of the repository's license file, if one is detected.
This endpoint supports the following custom media types. For more information, see "Media types."

application/vnd.github.raw+json: Returns the raw contents of the license.
application/vnd.github.html+json: Returns the license contents in HTML. Markup languages are rendered to HTML using GitHub's open-source Markup library.

### Parameters

#### Headers

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`owner`** (string) (required)
  The account owner of the repository. The name is not case sensitive.

* **`repo`** (string) (required)
  The name of the repository without the .git extension. The name is not case sensitive.

* **`ref`** (string)
  The Git reference for the results you want to list. The ref for a branch can be formatted either as refs/heads/<branch name> or simply <branch name>. To reference a pull request use refs/pull/<number>/merge.

### HTTP response status codes

* **200** - OK

* **404** - Resource not found

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X GET \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/license
```

**Response schema (Status: 200):**

* `name`: required, string
* `path`: required, string
* `sha`: required, string
* `size`: required, integer
* `url`: required, string, format: uri
* `html_url`: required, string or null, format: uri
* `git_url`: required, string or null, format: uri
* `download_url`: required, string or null, format: uri
* `type`: required, string
* `content`: required, string
* `encoding`: required, string
* `_links`: required, object:
  * `git`: required, string or null, format: uri
  * `html`: required, string or null, format: uri
  * `self`: required, string, format: uri
* `license`: required, any of:
  * **null**
  * **License Simple**
    * `key`: required, string
    * `name`: required, string
    * `url`: required, string or null, format: uri
    * `spdx_id`: required, string or null
    * `node_id`: required, string
    * `html_url`: string, format: uri