# Pontos de extremidade da API REST para licenças

Use a API REST para recuperar licenças populares open source e informações sobre um arquivo de licença de um projeto específico.

## Sobre licenças

GitHub usa [o open source Ruby Gem Licensee](https://github.com/benbalter/licensee) para tentar identificar a licença de um projeto. O Licensee compara o conteúdo do arquivo `LICENSE` de um projeto (caso exista) com uma pequena lista de licenças conhecidas. Como resultado, a API não leva em conta as licenças das dependências do projeto ou outros meios de documentar a licença de um projeto, como, por exemplo, referências ao nome da licença na documentação.

Se for encontrada a correspondência de uma licença, a chave de licença e o nome retornados estarão em conformidade com a [especificação SPDX](https://spdx.org/).

**Observação:** estas interfaces de API também retornarão as informações de licença de um repositório.

* [Obter um repositório](/pt/enterprise-server@3.21/rest/repos/repos#get-a-repository)
* [Listar os repositórios de um usuário](/pt/enterprise-server@3.21/rest/repos/repos#list-repositories-for-a-user)
* [Listar os repositórios da organização](/pt/enterprise-server@3.21/rest/repos/repos#list-organization-repositories)
* Listar os forks
* [Listar os repositórios inspecionados por um usuário](/pt/enterprise-server@3.21/rest/activity/watching#list-repositories-watched-by-a-user)
* [Listar os repositórios da equipe](/pt/enterprise-server@3.21/rest/teams/teams#list-team-repositories)

> \[!WARNING]
> GitHub é um monte de coisas, mas não é um escritório de advocacia. Dessa forma, a GitHub não fornece consultoria jurídica. Usar a API ou enviar-nos um email sobre a mesma não constitui aconselhamento jurídico, nem cria uma relação advogado e cliente. Em caso de dúvida sobre o que se pode e não se pode fazer com uma licença específica, antes de avançar, você deverá buscar orientação jurídica antes de seguir em frente. Na verdade, você deve sempre consultar o seu próprio advogado antes de tomar decisões que possam ter desdobramentos jurídicos ou que possam afetar seus direitos.
>
> GitHub criou estes pontos de extremidade para ajudar os usuários a obter informações sobre licenças e os projetos que as utilizam. Esperamos que ajude. No entanto, tenha em mente que não somos advogados (pelo menos a maioria de nós) e que cometemos erros como qualquer um. Por esse motivo, o GitHub fornece a API numa base "como se apresenta" e não faz garantias sobre quaisquer informações ou licenças fornecidas em ou através dela, além de eximir-se da responsabilidade por danos resultantes do uso da 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