List system packages from Fedora/RHEL database (yum)

Log in to Vote
3
3 Votes • 1 Comment
It's really cool how DuckDuckGo can show the packages from Debian/Ubuntu, but for Fedora and RHEL administrators (CentOS too) this isn't very useful, as package names are often different, and in some cases provide a totally different application.

It would
Source:
The Fedora Package Database has a JSON API that is easily accessible to determine whether or not a package exists.

For instance a package that does exist returns a bunch of JSON information, and a 200 OK status code.
https://admin.fedoraproject.org/pkgdb/api/packages/?pattern=httpd

If you supply a wildcard, chances are you'll get multiple packages returned. The first one is the most relevant.

If a package doesn't exist, we get a JSON error and a 404 status code returned.

Basic Perl example (Perl isn't my forte as you can tell :P)
Code:
require LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->timeout(2);
# probably a good idea to cache this locally. package names
#   don't change (and if they do, they probably 301 or "just work")
my $response = $ua->get('https://admin.fedoraproject.org/' .
'pkgdb/api/packages/?pattern=httpd');
my $exists = ($response->is_success && $response->status_line == 200);
print($exists);
• posted 3 years and 9 months ago • type: Spice (API calls) Under Review

Moollaza
A PR has been submitted and is under review: https://github.com/duckduckgo/zeroclicki...
posted by Moollaza Staff3 years and 4 months ago Link