Ubuntu – Does packages.ubuntu.com provide a search API


The Debian package directory provides a simple API to search for package releases. For instance this query results can be accessed as JSON at https://sources.debian.net/api/src/libtry-tiny-perl/. Is there a similar API for http://packages.ubuntu.com/?

Best Answer

As commented by muru, everything in Ubuntu is on Launchpad. Launchpad's API can also be used to search for package releases. To give an example:

To get API response as JSON, use curl:

$ curl https://api.launchpad.net/devel/ubuntu/+source/libtry-tiny-perl

Package releases can be queried with query parameter source_nameat base URL https://api.launchpad.net/1.0/ubuntu/+archive/primary?ws.op=getPublishedSources&&exact_match=true, for instance:

$ curl 'https://api.launchpad.net/1.0/ubuntu/+archive/primary?ws.op=getPublishedSources&source_name=libtry-tiny-perl&exact_match=true'

The API documentation is a bit complicated, even with the official API client launchpadlib so it took me some time to find out. The Ubuntu version of a package release is given in field distro_series_link.

Related Question