In addition to the human readable license deeds and legal code, Creative Commons provides machine readable metadata for licenses. This page describes how to begin with a license URI and map it to license properties.
License Properties describe the permissions, prohibitions and requirements of a license. Permissions declare a permission given by the license, above and beyond what default copyright law allows. Prohibitions prohibit a particular use of the work, specifically affecting the scope of the permissions provided by a permission. Requirements describe actions required of user when making use of the permissions.
There are two ways to discover license properties given a license URI:
- The "dumb" and easy way: Inspect the URL. This can be done with regular expressions or even simple string searching, but requires your code to bake in a little knowledge about CC license URI conventions, and will not work with possible future license URIs that do not follow these conventions (e.g., non-CC licenses that use CC style metadata). But this downside should be of little concern if all you want to do is discover CC licensed material and be able to remember and filter on high level properties such as whether commercial use or derviative works are prohibited.
- The smart and hard way: Use RDFa. This allows you to discover properties for any license URI, including properties that may not be encoded in URI conventions. However, use of this method requires your code to use a RDFa parser.
Inspecting the URL
Creative Commons license deed URLs, for version 4.0, have the following format:
Creative Commons license deed URLs, prior to version 4.0, have the following format:
The jurisdiction is optional. For example:
Is the URL for the Attribution 3.0 (Unported) license. The license is Unported as there is no jurisdiction element present. The Attribution 2.0 (France) license has the following URL:
Mapping Individual Properties
The license properties portion of the URL is a sequence a letter codes separated by dashes ("-"). These map to the following license properties:
- by: Attribution: Attribution is required with any reuse or redistribution, in the manner specified by the licensor.
- nc: Non-Commercial: Commercial use is prohibited.
- nd: No Derivatives: Only verbatim reproduction is permitted.
- sa: Share-Alike: Derivative works are allowed, but must also be licensed under the same license.
"""extract_simple.py Command line sample to map a Creative Commons license URI to the properties it describes. See http://wiki.creativecommons.org/License_Properties for details. Example usage: $ python extract_simple.py https://creativecommons.org/licenses/by/3.0/ Attribution $ python extract_simply.py https://creativecommons.org/licenses/by-nc/3.0/ Attribution Non-Commercial """ import sys import urlparse ATTRIBUTES = dict( by = 'Attribution', nc = 'Non-Commercial', nd = 'No Derivatives', sa = 'Share-Alike', ) def parse(url): """Return a sequence of attributes for the given license URL.""" # get the path portion of the URL path = urlparse.urlparse(url) # extract the license code portion pieces = path.split('/') assert(pieces == 'licenses') # split the individual codes attribute_codes = pieces.split('-') return [ATTRIBUTES[n] for n in attribute_codes] if __name__ == '__main__': print "\n".join( parse(sys.argv[-1]) )
For this URI, all of the properties above are false, but obviously the (implicit) properties of permitting distribution and derivative works are true.
The Sampling Licenses define specific permissions with respect to sampling a work. The license URLs are
https://creativecommons.org/licenses/sampling/1.0/ (retired) https://creativecommons.org/licenses/sampling+/1.0/ (retired) https://creativecommons.org/licenses/nc-sampling+/1.0/ (retired)
Many simple implementations may ignore these.
Source Code Licenses
Creative Commons provides metadata "wrappers" for some source code licenses. These URLs are:
https://creativecommons.org/licenses/MIT/ https://creativecommons.org/licenses/BSD/ https://creativecommons.org/licenses/GPL/2.0/ https://creativecommons.org/licenses/LGPL/2.1/
RDFa is an editor's draft at W3 which describes a way to serialize RDF triples in HTML. Creative Commons includes the appropriate RDFa When selecting a license from http://creativecommons.org/license to indicate that a page is licensed. For example:
<a href="http://creativecommons.org/licenses/by/3.0/" rel="license">Attribution 3.0</a>
rel="license" attribute indicates that the link specified (the license URL in this case) has special semantic meaning.
With the license URI, an RDFa parser may be used to extract license attributes from the human readable deed. RDFa parsers are available for many languages, including Python (RdfaDict, rdflib), Ruby (ruby-rdfa) and PHP (RDFa Monkey).
@prefix cc: <http://creativecommons.org/ns#> . http://creativecommons.org/licenses/by/3.0/ cc:requires cc:Attribution . http://creativecommons.org/licenses/by/3.0/ cc:requires cc:Notice . http://creativecommons.org/licenses/by/3.0/ cc:permits cc:Reproduction . http://creativecommons.org/licenses/by/3.0/ cc:permits cc:Distribution . http://creativecommons.org/licenses/by/3.0/ cc:permits cc:DerivativeWorks .
For a complete list of Permissions, Prohibitions and Requirements defined by Creative Commons see http://creativecommons.org/ns.
The following sample code uses RdfaDict to parse the license deed and prints the URIs for the license permissions, prohibitions and requirements.
"""extract_rdfa.py Command line sample to map a Creative Commons license URI to the properties it describes. See http://wiki.creativecommons.org/License_Properties for details. Example usage: $ python extract_rdfa.py http://creativecommons.org/licenses/by/3.0/ http://creativecommons.org/ns#Attribution http://creativecommons.org/ns#Notice http://creativecommons.org/ns#Reproduction http://creativecommons.org/ns#Distribution http://creativecommons.org/ns#DerivativeWorks $ python extract_rdfa.py http://creativecommons.org/licenses/by-nc/3.0/ http://creativecommons.org/ns#Attribution http://creativecommons.org/ns#Notice http://creativecommons.org/ns#CommercialUse http://creativecommons.org/ns#Reproduction http://creativecommons.org/ns#Distribution http://creativecommons.org/ns#DerivativeWorks Requires rdfadict (http://python.org/pypi/rdfadict). """ import sys import rdfadict def parse(url): """Return a sequence of attributes for the given license URL.""" # parse the license deed and extract RDFa rdf = rdfadict.RdfaParser().parseurl(url) # return all predicates (merging requirements, prohibitions and permissions) result =  for predicate in rdf[url]: for obj in rdf[url][predicate]: result.append(obj) return result if __name__ == '__main__': print "\n".join( parse(sys.argv[-1]) )