---
title: "Get the license for a repository"
method: GET
path: "/repos/{owner}/{repo}/license"
tags: ["licenses"]
---

# 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](https://docs.github.com/enterprise-cloud@latest/rest/using-the-rest-api/getting-started-with-the-rest-api#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](https://github.com/github/markup).

## Path parameters

- `owner` string, required
- `repo` string, required

## Query parameters

- `ref` string — The Git reference, formatted as `refs/pull/<number>/merge`, `refs/pull/<number>/head`, `refs/heads/<branch name>` or simply `<branch name>`.

## Response `200`

Response

- LicenseContent — License Content
  - `name` string, required
  - `path` string, required
  - `sha` string, required
  - `size` integer, required
  - `url` string, uri, required
  - `html_url` string, uri, nullable, required
  - `git_url` string, uri, nullable, required
  - `download_url` string, uri, nullable, required
  - `type` string, required
  - `content` string, required
  - `encoding` string, required
  - `_links` object, required
    - `git` string, uri, nullable, required
    - `html` string, uri, nullable, required
    - `self` string, uri, required
  - `license` NullableLicenseSimple, nullable, required — License Simple
    - `key` string, required
    - `name` string, required
    - `url` string, uri, nullable, required
    - `spdx_id` string, nullable, required
    - `node_id` string, required
    - `html_url` string, uri

## Other responses

- `404` — Resource not found

---

[API](https://skmtc.net/github/apis/github-v3-rest-api-2.md) · [All operations](https://skmtc.net/github/apis/github-v3-rest-api-2/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/github/github-v3-rest-api-2/versions/8ae6d0c8716e/schema)
