1. Perl
  2. CPAN

Get module information using metaCPAN API

It was very difficult with CPAN to get the file automatically by specifying the module name and version, but with the advent of metaCPAN, this situation is likely to change. It's about to change because the metaCPAN API is still in beta.

Still, the metaCPAN API is still useful. The API seems to be managed for each version, so I have a feeling that backward compatibility will be maintained.

Get information

You can get the information as follows.

  • http://api.metacpan.org/v0/release/_search?q=name:DBIx-Custom-0.2107&fields=download_url,name

When you actually access it, the information is returned in JSON format. If you look at download_url , you can see the URL of the actual location of the file.

A little commentary

This is Web API and JSON format data. You can set search conditions with q . name is searching for DBIx-Custom-0.2107. In fields , you can specify the items of the data you want to get. It seems that this can be specified separated by commas.

Also, the great thing is that it has only the name metaCPAN, which allows you to handle both CPAN and BackPAN information in a unified way. This means that even if your distribution is removed from CPAN, you can still access that information with metaCPAN.

metaCPAN makes CPAN even more convenient. Perl is becoming more and more convenient these days.

Related Informatrion