MetaCPAN::API(3)
π MetaCPAN::API β the manual, but make it a group chat π
okay bestie, so this is the page for MetaCPAN::API(3), part of the User Contributed Perl Documentation situation. And ngl, I have to tell you something right off the bat: this module is DEPRECATED. Like, "we don't talk about it" deprecated. But you're here, you're reading, so let's give it the full tour anyway, because it's honestly kinda iconic even in retirement. π«Ά
β¨ NAME β¨
MetaCPAN::API β a comprehensive, DWIM-featured API to MetaCPAN. Also: DEPRECATED. π
πΈ VERSION πΈ
version 0.51
π SYNOPSIS π
the simple usage, the little starter pack:
# simple usage
my $mcpan = MetaCPAN::API->new();
my $author = $mcpan->author('XSAWYERX');
my $dist = $mcpan->release( distribution => 'MetaCPAN-API' );
and then the advanced usage, with cache, which was contributed by Kent Fredric, shoutout to them π:
# advanced usage with cache (contributed by Kent Fredric)
require CHI;
require WWW::Mechanize::Cached;
require HTTP::Tiny::Mech;
require MetaCPAN::API;
my $mcpan = MetaCPAN::API->new(
ua => HTTP::Tiny::Mech->new(
mechua => WWW::Mechanize::Cached->new(
cache => CHI->new(
driver => 'File',
root_dir => '/tmp/metacpan-cache',
),
),
),
);
π¦ DESCRIPTION π¦
so back in the day, this was the original, hopefully-complete, API-compliant interface to MetaCPAN (<https://metacpan.org>). it was the moment. it was serving. and then... it got superseded by MetaCPAN::Client. the torch was passed, bestie. π₯
π DEPRECATED π
THIS MODULE IS DEPRECATED, DO NOT USE!
not me being dramatic, that's literally what it says. like, all caps and everything. π
this module has been completely rewritten to address a multitude of problems, and it now lives under its new official name: MetaCPAN::Client.
please do not use this module. fr fr. π
π ATTRIBUTES π
β¨ base_url β¨
my $mcpan = MetaCPAN::API->new(
base_url => 'http://localhost:9999',
);
this attribute is what you use for REST requests. you set it to wherever MetaCPAN is actually reachable. by default it's already set correctly, so no stress β but if you're running a local instance of MetaCPAN, or you use a local mirror, or you tunnel it through a local port, or literally any of those things, you're gonna want to change this.
Default: https://fastapi.metacpan.org/v1.
this attribute is read-only (immutable), meaning once it's set on initialize (via new()), you cannot change it. if you need to change it, create a new instance of MetaCPAN::API. and why is it immutable, you ask? because it's better. π
π ua π
this attribute holds the user agent used for running the REST request to the server. it is specifically set to HTTP::Tiny, so if you want to set it manually, make sure it's of HTTP::Tiny. no substitutions, bestie.
HTTP::Tiny is used as part of the philosophy of keeping it tiny. that's the whole vibe. β¨
this attribute is read-only (immutable), meaning once it's set on initialize (via new()), you cannot change it. if you need to, create a new instance of MetaCPAN::API. why is it immutable? because it's better. (yes, same line, it's a whole thing, it's giving catchphrase)
π ua_args π
my $mcpan = MetaCPAN::API->new(
ua_args => [ agent => 'MyAgent' ],
);
the arguments that get handed to the HTTP::Tiny user agent.
this attribute is read-only (immutable), meaning once it's set on initialize (via new()), you cannot change it. if you need to, create a new instance of MetaCPAN::API. why is it immutable? because it's better. (again. consistent queen.)
the default is a user agent string: MetaCPAN::API/$version.
π§ METHODS π§
β fetch β
my $result = $mcpan->fetch('/release/distribution/Moose');
# with parameters
my $more = $mcpan->fetch(
'/release/distribution/Moose',
param => 'value',
);
this is a helper method for API implementations. it fetches a path from MetaCPAN, decodes the JSON from the content variable, and returns it. that's the whole job. clean. simple. slay. π
you don't really need to use it, but you can, in case you want to write your own extension implementation to MetaCPAN::API. main character energy, honestly.
it accepts an additional hash as GET parameters.
πΈ post πΈ
# /release&content={"query":{"match_all":{}},"filter":{"prefix":{"archive":"Cache-Cache-1.06"}}}
my $result = $mcpan->post(
'release',
{
query => { match_all => {} },
filter => { prefix => { archive => 'Cache-Cache-1.06' } },
},
);
the POST equivalent of the fetch() method. it gets the path and the JSON request. that's it, that's the method. β¨
π AUTHOR π
Sawyer X <xsawyerx@cpan.org>
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2011 by Sawyer X.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
okay and that's the whole page, bestie!! π«Ά this manual page is from perl v5.42.0, dated 2025-07-25, and the page itself is MetaCPAN::API(3). mwah, love that for us. go use MetaCPAN::Client though. seriously. πβ¨π
π¦ where this page comes from
- fedora 43: perl-MetaCPAN-API 0.51-24.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms