Skip to content

Licenses

client.licenses covers the /licenses list route, which lists the license URIs Crossref records carry. Crossref has no single-license route, so licenses.get() and licenses.exists() raise ConfigurationError.

The route accepts no query. Every query returns a total of 0 while the plain list serves about 30,000 entries. Call search() without a query and filter the results yourself, or use the license.url, license.version, and license.delay filters on works (see Works).

import asyncio

from bibliofabric.crossref import CrossrefClient


client = CrossrefClient()


async def main() -> None:
    async with client:
        page = await client.licenses.search(page_size=3)
        print("total:", page.total)
        for lic in page.results:
            print(" ", lic.url, lic.work_count)


asyncio.run(main())
total: 29768
  HTTPS://CREATIVECOMMONS.ORG/LICENSES/BY/4.0/ 1
  Http://creativecommons.org/license/by-nc/4.0. 100
  Http://creativecommons.org/licenses/by-nc/4.0 2

License URIs arrive with inconsistent casing, so compare them case-insensitively.

iterate() pages with offset (Crossref does not support cursor on /licenses), and collect(), first(), and count() are available:

n = 0
async for lic in client.licenses.iterate(page_size=100, limit=2):
    n += 1
print("iterated:", n)
iterated: 2