pub-dev icon indicating copy to clipboard operation
pub-dev copied to clipboard

Add 'licence' field to /api/packages/<package> endpoint

Open delliot opened this issue 1 year ago • 3 comments

I have a usecase where I need to cache licenses for Pub packages. It's currently possible to download each version archive tarball and examine the license file, but it would save downloading tarballs if you were able to add a 'license' field to either the top level package object, or to each version object as returned by the /api/packages/<package> endpoint.

It is currently possible to get the rest of this metadata (if available) from the pubspec field, but the license data is only possible by parsing the HTML or tarball.

image

// Current object:

{
        "version": "",
        "pubspec": {},
        "license": "MIT" // Suggested new field
        "archive_url": "",
        "archive_sha256": "",
        "published": ""
},

delliot avatar Feb 09 '24 19:02 delliot

I don't think we'll extend the version listing api with this information.

The only official apis we support are documented on: https://pub.dev/help/api

There is the unofficial https://pub.dev/api/packages/<package>/score it contains the derived license.

Don't build a big pipeline on it, as we might change it in the future without warning.

sigurdm avatar Feb 12 '24 09:02 sigurdm

I have a usecase where I need to cache licenses for Pub packages.

Could you please share more about the use-case and how we may serve it better?

There is the unofficial https://pub.dev/api/packages//score it contains the derived license.

Please take this seriously. We don't support APIs outside of the ones on the linked help page.

isoos avatar Feb 12 '24 10:02 isoos

👋 from the GitHub dependency graph team. We'd also love to have this data in the API, as it would help us report on license information in Dart packages. Currently we don't have it since there isn't an authoritative API to source this data from, limiting Dart from being able to use features like dependency review. We'd love to offer this to our many shared users.

jonjanego avatar Mar 04 '24 19:03 jonjanego