GitHub Licenses API

The GitHub Licenses API lets you programmatically discover and retrieve open source license information across GitHub. It provides endpoints to list the common licenses GitHub supports, get detailed metadata and the canonical text for a specific license (by its SPDX identifier), and fetch the detected license for a given repository.

Operations 3

GET /licenses GitHub Get All Commonly Used Licenses #
GET /licenses/{license} GitHub Get a License #
GET /repos/{owner}/{repo}/license GitHub Get the License for a Repository #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/github-licenses-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

github-licenses-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  version: 1.1.4
  title: GitHub v3 REST Licenses API
  description: GitHub's v3 REST API.
  license:
    name: MIT
    url: https://spdx.org/licenses/MIT
  termsOfService: https://docs.github.com/articles/github-terms-of-service
  contact:
    name: Support
    url: https://support.github.com/contact?tags=dotcom-rest-api
  x-github-plan: ghes
  x-github-release: 3.9
servers:
- url: '{protocol}://{hostname}/api/v3'
  variables:
    hostname:
      description: Self-hosted Enterprise Server hostname
      default: HOSTNAME
    protocol:
      description: Self-hosted Enterprise Server protocol
      default: http
tags:
- name: Licenses
  description: View various OSS licenses.
paths:
  /licenses:
    get:
      summary: GitHub Get All Commonly Used Licenses
      description: Lists the most commonly used licenses on GitHub. For more information, see "[Licensing a repository ](https://docs.github.com/enterprise-server@3.9/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/licensing-a-repository)."
      tags:
      - Licenses
      operationId: licenses/get-all-commonly-used
      externalDocs:
        description: API method documentation
        url: https://docs.github.com/enterprise-server@3.9/rest/licenses/licenses#get-all-commonly-used-licenses
      parameters:
      - name: featured
        in: query
        required: false
        schema:
          type: boolean
        example: true
      - $ref: '#/components/parameters/per-page'
      - $ref: '#/components/parameters/page'
      responses:
        '200':
          description: Response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/license-simple'
              examples:
                default:
                  $ref: '#/components/examples/license-simple-items'
        '304':
          $ref: '#/components/responses/not_modified'
      x-github:
        githubCloudOnly: false
        enabledForGitHubApps: true
        category: licenses
        subcategory: licenses
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
  /licenses/{license}:
    get:
      summary: GitHub Get a License
      description: Gets information about a specific license. For more information, see "[Licensing a repository ](https://docs.github.com/enterprise-server@3.9/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/licensing-a-repository)."
      tags:
      - Licenses
      operationId: licenses/get
      externalDocs:
        description: API method documentation
        url: https://docs.github.com/enterprise-server@3.9/rest/licenses/licenses#get-a-license
      parameters:
      - name: license
        in: path
        required: true
        schema:
          type: string
        example: example_value
      responses:
        '200':
          description: Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/license'
              examples:
                default:
                  $ref: '#/components/examples/license'
        '304':
          $ref: '#/components/responses/not_modified'
        '403':
          $ref: '#/components/responses/forbidden'
        '404':
          $ref: '#/components/responses/not_found'
      x-github:
        githubCloudOnly: false
        enabledForGitHubApps: true
        category: licenses
        subcategory: licenses
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
  /repos/{owner}/{repo}/license:
    get:
      summary: GitHub Get the License for a Repository
      description: '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-server@3.9/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).'
      tags:
      - Licenses
      operationId: licenses/get-for-repo
      externalDocs:
        description: API method documentation
        url: https://docs.github.com/enterprise-server@3.9/rest/licenses/licenses#get-the-license-for-a-repository
      parameters:
      - $ref: '#/components/parameters/owner'
      - $ref: '#/components/parameters/repo'
      responses:
        '200':
          description: Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/license-content'
              examples:
                default:
                  $ref: '#/components/examples/license-content'
        '404':
          $ref: '#/components/responses/not_found'
      x-github:
        githubCloudOnly: false
        enabledForGitHubApps: true
        category: licenses
        subcategory: licenses
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
components:
  examples:
    license-simple-items:
      value:
      - key: mit
        name: MIT License
        spdx_id: MIT
        url: https://api.github.com/licenses/mit
        node_id: MDc6TGljZW5zZW1pdA==
      - key: lgpl-3.0
        name: GNU Lesser General Public License v3.0
        spdx_id: LGPL-3.0
        url: https://api.github.com/licenses/lgpl-3.0
        node_id: MDc6TGljZW5zZW1pdA==
      - key: mpl-2.0
        name: Mozilla Public License 2.0
        spdx_id: MPL-2.0
        url: https://api.github.com/licenses/mpl-2.0
        node_id: MDc6TGljZW5zZW1pdA==
      - key: agpl-3.0
        name: GNU Affero General Public License v3.0
        spdx_id: AGPL-3.0
        url: https://api.github.com/licenses/agpl-3.0
        node_id: MDc6TGljZW5zZW1pdA==
      - key: unlicense
        name: The Unlicense
        spdx_id: Unlicense
        url: https://api.github.com/licenses/unlicense
        node_id: MDc6TGljZW5zZW1pdA==
      - key: apache-2.0
        name: Apache License 2.0
        spdx_id: Apache-2.0
        url: https://api.github.com/licenses/apache-2.0
        node_id: MDc6TGljZW5zZW1pdA==
      - key: gpl-3.0
        name: GNU General Public License v3.0
        spdx_id: GPL-3.0
        url: https://api.github.com/licenses/gpl-3.0
        node_id: MDc6TGljZW5zZW1pdA==
    license:
      value:
        key: mit
        name: MIT License
        spdx_id: MIT
        url: https://api.github.com/licenses/mit
        node_id: MDc6TGljZW5zZW1pdA==
        html_url: http://choosealicense.com/licenses/mit/
        description: A permissive license that is short and to the point. It lets people do anything with your code with proper attribution and without warranty.
        implementation: Create a text file (typically named LICENSE or LICENSE.txt) in the root of your source code and copy the text of the license into the file. Replace [year] with the current year and [fullname] with the name (or names) of the copyright holders.
        permissions:
        - commercial-use
        - modifications
        - distribution
        - sublicense
        - private-use
        conditions:
        - include-copyright
        limitations:
        - no-liability
        body: '


          The MIT License (MIT)


          Copyright (c) [year] [fullname]


          Permission is hereby granted, free of charge, to any person obtaining a copy

          of this software and associated documentation files (the "Software"), to deal

          in the Software without restriction, including without limitation the rights

          to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

          copies of the Software, and to permit persons to whom the Software is

          furnished to do so, subject to the following conditions:


          The above copyright notice and this permission notice shall be included in all

          copies or substantial portions of the Software.


          THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

          IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

          FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

          AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER

          LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,

          OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

          SOFTWARE.

          '
        featured: true
    license-content:
      value:
        name: LICENSE
        path: LICENSE
        sha: 401c59dcc4570b954dd6d345e76199e1f4e76266
        size: 1077
        url: https://api.github.com/repos/benbalter/gman/contents/LICENSE?ref=master
        html_url: https://github.com/benbalter/gman/blob/master/LICENSE
        git_url: https://api.github.com/repos/benbalter/gman/git/blobs/401c59dcc4570b954dd6d345e76199e1f4e76266
        download_url: https://raw.githubusercontent.com/benbalter/gman/master/LICENSE?lab=true
        type: file
        content: 'VGhlIE1JVCBMaWNlbnNlIChNSVQpCgpDb3B5cmlnaHQgKGMpIDIwMTMgQmVu

          IEJhbHRlcgoKUGVybWlzc2lvbiBpcyBoZXJlYnkgZ3JhbnRlZCwgZnJlZSBv

          ZiBjaGFyZ2UsIHRvIGFueSBwZXJzb24gb2J0YWluaW5nIGEgY29weSBvZgp0

          aGlzIHNvZnR3YXJlIGFuZCBhc3NvY2lhdGVkIGRvY3VtZW50YXRpb24gZmls

          ZXMgKHRoZSAiU29mdHdhcmUiKSwgdG8gZGVhbCBpbgp0aGUgU29mdHdhcmUg

          d2l0aG91dCByZXN0cmljdGlvbiwgaW5jbHVkaW5nIHdpdGhvdXQgbGltaXRh

          dGlvbiB0aGUgcmlnaHRzIHRvCnVzZSwgY29weSwgbW9kaWZ5LCBtZXJnZSwg

          cHVibGlzaCwgZGlzdHJpYnV0ZSwgc3VibGljZW5zZSwgYW5kL29yIHNlbGwg

          Y29waWVzIG9mCnRoZSBTb2Z0d2FyZSwgYW5kIHRvIHBlcm1pdCBwZXJzb25z

          IHRvIHdob20gdGhlIFNvZnR3YXJlIGlzIGZ1cm5pc2hlZCB0byBkbyBzbywK

          c3ViamVjdCB0byB0aGUgZm9sbG93aW5nIGNvbmRpdGlvbnM6CgpUaGUgYWJv

          dmUgY29weXJpZ2h0IG5vdGljZSBhbmQgdGhpcyBwZXJtaXNzaW9uIG5vdGlj

          ZSBzaGFsbCBiZSBpbmNsdWRlZCBpbiBhbGwKY29waWVzIG9yIHN1YnN0YW50

          aWFsIHBvcnRpb25zIG9mIHRoZSBTb2Z0d2FyZS4KClRIRSBTT0ZUV0FSRSBJ

          UyBQUk9WSURFRCAiQVMgSVMiLCBXSVRIT1VUIFdBUlJBTlRZIE9GIEFOWSBL

          SU5ELCBFWFBSRVNTIE9SCklNUExJRUQsIElOQ0xVRElORyBCVVQgTk9UIExJ

          TUlURUQgVE8gVEhFIFdBUlJBTlRJRVMgT0YgTUVSQ0hBTlRBQklMSVRZLCBG

          SVRORVNTCkZPUiBBIFBBUlRJQ1VMQVIgUFVSUE9TRSBBTkQgTk9OSU5GUklO

          R0VNRU5ULiBJTiBOTyBFVkVOVCBTSEFMTCBUSEUgQVVUSE9SUyBPUgpDT1BZ

          UklHSFQgSE9MREVSUyBCRSBMSUFCTEUgRk9SIEFOWSBDTEFJTSwgREFNQUdF

          UyBPUiBPVEhFUiBMSUFCSUxJVFksIFdIRVRIRVIKSU4gQU4gQUNUSU9OIE9G

          IENPTlRSQUNULCBUT1JUIE9SIE9USEVSV0lTRSwgQVJJU0lORyBGUk9NLCBP

          VVQgT0YgT1IgSU4KQ09OTkVDVElPTiBXSVRIIFRIRSBTT0ZUV0FSRSBPUiBU

          SEUgVVNFIE9SIE9USEVSIERFQUxJTkdTIElOIFRIRSBTT0ZUV0FSRS4K

          '
        encoding: base64
        _links:
          self: https://api.github.com/repos/benbalter/gman/contents/LICENSE?ref=master
          git: https://api.github.com/repos/benbalter/gman/git/blobs/401c59dcc4570b954dd6d345e76199e1f4e76266
          html: https://github.com/benbalter/gman/blob/master/LICENSE
        license:
          key: mit
          name: MIT License
          spdx_id: MIT
          url: https://api.github.com/licenses/mit
          node_id: MDc6TGljZW5zZW1pdA==
  responses:
    forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/basic-error'
    not_found:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/basic-error'
    not_modified:
      description: Not modified
  schemas:
    nullable-license-simple:
      title: License Simple
      description: License Simple
      type:
      - object
      - 'null'
      properties:
        key:
          type: string
          example: mit
        name:
          type: string
          example: MIT License
        url:
          type:
          - string
          - 'null'
          format: uri
          example: https://api.github.com/licenses/mit
        spdx_id:
          type:
          - string
          - 'null'
          example: MIT
        node_id:
          type: string
          example: MDc6TGljZW5zZW1pdA==
        html_url:
          type: string
          format: uri
          example: https://api.github.com/repos/octocat/Hello-World
      required:
      - key
      - name
      - url
      - spdx_id
      - node_id
    license-content:
      title: License Content
      description: License Content
      type: object
      properties:
        name:
          type: string
          example: octocat
        path:
          type: string
          example: src/index.js
        sha:
          type: string
          example: abc123def456789012345678901234567890
        size:
          type: integer
          example: 42
        url:
          type: string
          format: uri
          example: https://api.github.com/repos/octocat/Hello-World
        html_url:
          type:
          - string
          - 'null'
          format: uri
          example: https://api.github.com/repos/octocat/Hello-World
        git_url:
          type:
          - string
          - 'null'
          format: uri
          example: https://api.github.com/repos/octocat/Hello-World
        download_url:
          type:
          - string
          - 'null'
          format: uri
          example: https://api.github.com/repos/octocat/Hello-World
        type:
          type: string
          example: User
        content:
          type: string
          example: example_value
        encoding:
          type: string
          example: example_value
        _links:
          type: object
          properties:
            git:
              type:
              - string
              - 'null'
              format: uri
            html:
              type:
              - string
              - 'null'
              format: uri
            self:
              type: string
              format: uri
          required:
          - git
          - html
          - self
        license:
          $ref: '#/components/schemas/nullable-license-simple'
      required:
      - _links
      - git_url
      - html_url
      - download_url
      - name
      - path
      - sha
      - size
      - type
      - url
      - content
      - encoding
      - license
    license-simple:
      title: License Simple
      description: License Simple
      type: object
      properties:
        key:
          type: string
          example: mit
        name:
          type: string
          example: MIT License
        url:
          type:
          - string
          - 'null'
          format: uri
          example: https://api.github.com/licenses/mit
        spdx_id:
          type:
          - string
          - 'null'
          example: MIT
        node_id:
          type: string
          example: MDc6TGljZW5zZW1pdA==
        html_url:
          type: string
          format: uri
          example: https://api.github.com/repos/octocat/Hello-World
      required:
      - key
      - name
      - url
      - spdx_id
      - node_id
    license:
      title: License
      description: License
      type: object
      properties:
        key:
          type: string
          example: mit
        name:
          type: string
          example: MIT License
        spdx_id:
          type:
          - string
          - 'null'
          example: MIT
        url:
          type:
          - string
          - 'null'
          format: uri
          example: https://api.github.com/licenses/mit
        node_id:
          type: string
          example: MDc6TGljZW5zZW1pdA==
        html_url:
          type: string
          format: uri
          example: http://choosealicense.com/licenses/mit/
        description:
          type: string
          example: A permissive license that is short and to the point. It lets people do anything with your code with proper attribution and without warranty.
        implementation:
          type: string
          example: Create a text file (typically named LICENSE or LICENSE.txt) in the root of your source code and copy the text of the license into the file. Replace [year] with the current year and [fullname] with the name (or names) of the copyright holders.
        permissions:
          type: array
          example:
          - commercial-use
          - modifications
          - distribution
          - sublicense
          - private-use
          items:
            type: string
        conditions:
          type: array
          example:
          - include-copyright
          items:
            type: string
        limitations:
          type: array
          example:
          - no-liability
          items:
            type: string
        body:
          type: string
          example: '


            The MIT License (MIT)


            Copyright (c) [year] [fullname]


            Permission is hereby granted, free of charge, to any person obtaining a copy

            of this software and associated documentation files (the "Software"), to deal

            in the Software without restriction, including without limitation the rights

            to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

            copies of the Software, and to permit persons to whom the Software is

            furnished to do so, subject to the following conditions:


            The above copyright notice and this permission notice shall be included in all

            copies or substantial portions of the Software.


            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER

            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,

            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

            SOFTWARE.

            '
        featured:
          type: boolean
          example: true
      required:
      - key
      - name
      - url
      - spdx_id
      - node_id
      - html_url
      - description
      - implementation
      - permissions
      - conditions
      - limitations
      - body
      - featured
    basic-error:
      title: Basic Error
      description: Basic Error
      type: object
      properties:
        message:
          type: string
          example: Example body text
        documentation_url:
          type: string
          example: https://api.github.com/repos/octocat/Hello-World
        url:
          type: string
          example: https://api.github.com/repos/octocat/Hello-World
        status:
          type: string
          example: open
  parameters:
    repo:
      name: repo
      description: The name of the repository without the `.git` extension. The name is not case sensitive.
      in: path
      required: true
      schema:
        type: string
    owner:
      name: owner
      description: The account owner of the repository. The name is not case sensitive.
      in: path
      required: true
      schema:
        type: string
    per-page:
      name: per_page
      description: The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/enterprise-server@3.9/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
      in: query
      schema:
        type: integer
        default: 30
    page:
      name: page
      description: The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/enterprise-server@3.9/rest/using-the-rest-api/using-pagination-in-the-rest-api)."
      in: query
      schema:
        type: integer
        default: 1
externalDocs:
  description: GitHub Enterprise Developer Docs
  url: https://docs.github.com/enterprise-server@3.9/rest/