Skip to content
This repository was archived by the owner on Nov 1, 2017. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions content/changes/2015-03-09-licenses-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
kind: change
title: Licenses API
created_at: 2015-03-09
author_name: benbalter
---

We're introducing a new [license API](/v3/licenses) preview to support [open source license usage on GitHub.com](https://github.com/blog/1964-license-usage-on-github-com).

To access the API during the preview period, you must provide a custom [media type](/v3/media) in the `Accept` header:

application/vnd.github.drax-preview+json

This will then expose two new API endpoints. You can get a list of all known licenses:

GET /licenses

Or get information about a particular license:

GET /licenses/mit

When the preview media type is passed, the repository api will also return information about a repository's license file when you get an individual repository:

GET /repos/github/hubot

For more information, see the [licenses API documentation](/v3/licenses/), and if you have any questions or feedback, please [let us know](https://github.com/contact?form%5Bsubject%5D=Licenses+API).
63 changes: 63 additions & 0 deletions content/v3/licenses.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
title: Licenses | GitHub API
---

# Licenses

* TOC
{:toc}

{{#tip}}

<a name="preview-period"></a>

The Licenses API is currently available for developers to preview.
During the preview period, the API may change without advance notice.
Please see the [blog post][https://github.com/blog/1964-open-source-license-usage-on-github-com] for full details.

To access the API during the preview period, you must provide a custom [media type](/v3/media) in the `Accept` header:

application/vnd.github.drax-preview+json

{{/tip}}

The Licenses API returns metadata about popular open source licenses and information about a particular project's license file. The license key and name conforms to the [SPDX specification](https://spdx.org/).

{{#warning}}

GitHub is a lot of things, but it’s not a law firm. As such, GitHub does not provide legal advice. Using the Licenses API or sending us an email about it does not constitute legal advice nor does it create an attorney-client relationship. If you have any questions about what you can and can't do with a particular license, you should consult with your own legal counsel before moving forward. In fact, you should always consult with your own lawyer before making any decisions that might have legal ramifications or that may impact your legal rights.

GitHub created the License API to help users get information about open source licenses and the projects that use them. We hope it helps, but please keep in mind that we’re not lawyers (at least not most of us aren't) and that we make mistakes like everyone else. For that reason, GitHub provides the API on an “as-is” basis and makes no warranties regarding any information or licenses provided on or through it, and disclaims liability for damages resulting from using the API.

{{/warning}}

## List all licenses

GET /licenses

### Response

<%= headers 200 %>
<%= json(:licenses) %>

## Get an individual license

GET /licenses/mit

### Response

<%= headers 200 %>
<%= json(:mit) %>

## Get a repository's license

When passed the preview media type, requests to get a repository will also return the repository's license, if it can be detected from the repository's license file.

It's important to note that the API simply attempts to identity the project's license by the contents of the a `LICENSE` file, if any, and does not take into account the licenses of project dependencies or other means of documenting a project's license such as references in the documentation.

GET /repos/github/hubot

### Response

<%= headers 200 %>
<%= json(:licensee) %>
5 changes: 5 additions & 0 deletions content/v3/misc.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ organization's [GitHub Enterprise](https://enterprise.github.com/) installation.
The [Rate Limit API][Rate Limit] lets you check your current rate limit
status at any time.

## [Licenses][]

The [Licenses API][Licenses] returns information about open source licenses or under what license, if any a given project is distributed.

[Emojis]: /v3/emojis
[Gitignore]: /v3/gitignore
[Markdown]: /v3/markdown
[Meta]: /v3/meta
[Rate Limit]: /v3/rate_limit
[Licenses]: /v3/licenses
130 changes: 130 additions & 0 deletions lib/resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2307,6 +2307,136 @@ def fetch_content(key)
LDAP_SYNC_CONFIRM ||= {
'status' => 'queued'
}

LICENSES ||= [
{"key"=>"agpl-3.0", "name"=>"GNU Affero GPL v3.0", "url"=>"https://api.github.com/licenses/agpl-3.0"},
{"key"=>"apache-2.0", "name"=>"Apache License 2.0", "url"=>"https://api.github.com/licenses/apache-2.0"},
{"key"=>"artistic-2.0", "name"=>"Artistic License 2.0", "url"=>"https://api.github.com/licenses/artistic-2.0"},
{"key"=>"bsd-2-clause", "name"=>"Simplified BSD", "url"=>"https://api.github.com/licenses/bsd-2-clause"},
{"key"=>"bsd-3-clause", "name"=>"New BSD", "url"=>"https://api.github.com/licenses/bsd-3-clause"},
{"key"=>"cc0", "name"=>"CC0 1.0 Universal", "url"=>"https://api.github.com/licenses/cc0"},
{"key"=>"epl-1.0", "name"=>"Eclipse Public License v1.0", "url"=>"https://api.github.com/licenses/epl-1.0"},
{"key"=>"gpl-2.0", "name"=>"GNU GPL v2.0", "url"=>"https://api.github.com/licenses/gpl-2.0"},
{"key"=>"gpl-3.0", "name"=>"GNU GPL v3.0", "url"=>"https://api.github.com/licenses/gpl-3.0"},
{"key"=>"isc", "name"=>"ISC license", "url"=>"https://api.github.com/licenses/isc"},
{"key"=>"lgpl-2.1", "name"=>"GNU LGPL v2.1", "url"=>"https://api.github.com/licenses/lgpl-2.1"},
{"key"=>"lgpl-3.0", "name"=>"GNU LGPL v3.0", "url"=>"https://api.github.com/licenses/lgpl-3.0"},
{"key"=>"mit", "name"=>"MIT License", "url"=>"https://api.github.com/licenses/mit"},
{"key"=>"mpl-2.0", "name"=>"Mozilla Public License 2.0", "url"=>"https://api.github.com/licenses/mpl-2.0"},
{"key"=>"unlicense", "name"=>"Public Domain (Unlicense)", "url"=>"https://api.github.com/licenses/unlicense"}
]

MIT ||= {
"key"=>"mit",
"name"=>"MIT License",
"url"=>"https://api.github.com/licenses/mit",
"html_url"=>"http://choosealicense.com/licenses/mit/",
"featured"=>true,
"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.",
"category"=>"MIT",
"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.",
"required"=>["include-copyright"],
"permitted"=>["commercial-use", "modifications", "distribution", "sublicense", "private-use"],
"forbidden"=>["no-liability"],
"body"=>
"\n\nThe MIT License (MIT)\n\nCopyright (c) [year] [fullname]\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
}

LICENSEE ||= {
"id"=>23022377,
"name"=>"licensee",
"full_name"=>"benbalter/licensee",
"owner"=>{
"login"=>"benbalter",
"id"=>282759,
"avatar_url"=>"https://avatars.githubusercontent.com/u/282759?v=3",
"gravatar_id"=>"",
"url"=>"https://api.github.com/users/benbalter",
"html_url"=>"https://github.com/benbalter",
"followers_url"=>"https://api.github.com/users/benbalter/followers",
"following_url"=>"https://api.github.com/users/benbalter/following{/other_user}",
"gists_url"=>"https://api.github.com/users/benbalter/gists{/gist_id}",
"starred_url"=>"https://api.github.com/users/benbalter/starred{/owner}{/repo}",
"subscriptions_url"=>"https://api.github.com/users/benbalter/subscriptions",
"organizations_url"=>"https://api.github.com/users/benbalter/orgs",
"repos_url"=>"https://api.github.com/users/benbalter/repos",
"events_url"=>"https://api.github.com/users/benbalter/events{/privacy}",
"received_events_url"=>"https://api.github.com/users/benbalter/received_events",
"type"=>"User",
"site_admin"=>true
},
"private"=>false,
"html_url"=>"https://github.com/benbalter/licensee",
"description"=>"A Ruby Gem to detect under what license a project is distributed.",
"fork"=>false, "url"=>"https://api.github.com/repos/benbalter/licensee",
"forks_url"=>"https://api.github.com/repos/benbalter/licensee/forks",
"keys_url"=>"https://api.github.com/repos/benbalter/licensee/keys{/key_id}",
"collaborators_url"=>"https://api.github.com/repos/benbalter/licensee/collaborators{/collaborator}",
"teams_url"=>"https://api.github.com/repos/benbalter/licensee/teams",
"hooks_url"=>"https://api.github.com/repos/benbalter/licensee/hooks",
"issue_events_url"=>"https://api.github.com/repos/benbalter/licensee/issues/events{/number}",
"events_url"=>"https://api.github.com/repos/benbalter/licensee/events",
"assignees_url"=>"https://api.github.com/repos/benbalter/licensee/assignees{/user}",
"branches_url"=>"https://api.github.com/repos/benbalter/licensee/branches{/branch}",
"tags_url"=>"https://api.github.com/repos/benbalter/licensee/tags",
"blobs_url"=>"https://api.github.com/repos/benbalter/licensee/git/blobs{/sha}",
"git_tags_url"=>"https://api.github.com/repos/benbalter/licensee/git/tags{/sha}",
"git_refs_url"=>"https://api.github.com/repos/benbalter/licensee/git/refs{/sha}",
"trees_url"=>"https://api.github.com/repos/benbalter/licensee/git/trees{/sha}",
"statuses_url"=>"https://api.github.com/repos/benbalter/licensee/statuses/{sha}",
"languages_url"=>"https://api.github.com/repos/benbalter/licensee/languages",
"stargazers_url"=>"https://api.github.com/repos/benbalter/licensee/stargazers",
"contributors_url"=>"https://api.github.com/repos/benbalter/licensee/contributors",
"subscribers_url"=>"https://api.github.com/repos/benbalter/licensee/subscribers",
"subscription_url"=>"https://api.github.com/repos/benbalter/licensee/subscription",
"commits_url"=>"https://api.github.com/repos/benbalter/licensee/commits{/sha}",
"git_commits_url"=>"https://api.github.com/repos/benbalter/licensee/git/commits{/sha}",
"comments_url"=>"https://api.github.com/repos/benbalter/licensee/comments{/number}",
"issue_comment_url"=>"https://api.github.com/repos/benbalter/licensee/issues/comments{/number}",
"contents_url"=>"https://api.github.com/repos/benbalter/licensee/contents/{+path}",
"compare_url"=>"https://api.github.com/repos/benbalter/licensee/compare/{base}...{head}",
"merges_url"=>"https://api.github.com/repos/benbalter/licensee/merges",
"archive_url"=>"https://api.github.com/repos/benbalter/licensee/{archive_format}{/ref}",
"downloads_url"=>"https://api.github.com/repos/benbalter/licensee/downloads",
"issues_url"=>"https://api.github.com/repos/benbalter/licensee/issues{/number}",
"pulls_url"=>"https://api.github.com/repos/benbalter/licensee/pulls{/number}",
"milestones_url"=>"https://api.github.com/repos/benbalter/licensee/milestones{/number}",
"notifications_url"=>"https://api.github.com/repos/benbalter/licensee/notifications{?since,all,participating}",
"labels_url"=>"https://api.github.com/repos/benbalter/licensee/labels{/name}",
"releases_url"=>"https://api.github.com/repos/benbalter/licensee/releases{/id}",
"created_at"=>"2014-08-16T16:39:56Z",
"updated_at"=>"2015-02-26T18:58:36Z",
"pushed_at"=>"2015-02-26T19:09:18Z",
"git_url"=>"git://github.com/benbalter/licensee.git",
"ssh_url"=>"git@github.com:benbalter/licensee.git",
"clone_url"=>"https://github.com/benbalter/licensee.git",
"svn_url"=>"https://github.com/benbalter/licensee",
"homepage"=>"",
"size"=>687,
"stargazers_count"=>20,
"watchers_count"=>20,
"language"=>"Ruby",
"has_issues"=>true,
"has_downloads"=>true,
"has_wiki"=>false,
"has_pages"=>false,
"forks_count"=>6,
"mirror_url"=>nil,
"open_issues_count"=>2,
"forks"=>6,
"open_issues"=>2,
"watchers"=>20,
"default_branch"=>"master",
"master_branch"=>"master",
"license"=> {
"key"=>"mit",
"name"=>"MIT License",
"url"=>"https://api.github.com/licenses/mit"
},
"network_count"=>6,
"subscribers_count"=>6
}
end
end

Expand Down