1MetaCPAN::API(3)      User Contributed Perl Documentation     MetaCPAN::API(3)
2
3
4

NAME

6       MetaCPAN::API - A comprehensive, DWIM-featured API to MetaCPAN
7       (DEPRECATED)
8

VERSION

10       version 0.51
11

SYNOPSIS

13           # simple usage
14           my $mcpan  = MetaCPAN::API->new();
15           my $author = $mcpan->author('XSAWYERX');
16           my $dist   = $mcpan->release( distribution => 'MetaCPAN-API' );
17
18           # advanced usage with cache (contributed by Kent Fredric)
19           require CHI;
20           require WWW::Mechanize::Cached;
21           require HTTP::Tiny::Mech;
22           require MetaCPAN::API;
23
24           my $mcpan = MetaCPAN::API->new(
25             ua => HTTP::Tiny::Mech->new(
26               mechua => WWW::Mechanize::Cached->new(
27                 cache => CHI->new(
28                   driver => 'File',
29                   root_dir => '/tmp/metacpan-cache',
30                 ),
31               ),
32             ),
33           );
34

DESCRIPTION

36       This was the original hopefully-complete API-compliant interface to
37       MetaCPAN (<https://metacpan.org>).  It has now been superseded by
38       MetaCPAN::Client.
39

DEPRECATED

41       THIS MODULE IS DEPRECATED, DO NOT USE!
42
43       This module has been completely rewritten to address a multitude of
44       problems, and is now available under the new official name:
45       MetaCPAN::Client.
46
47       Please do not use this module.
48

ATTRIBUTES

50   base_url
51           my $mcpan = MetaCPAN::API->new(
52               base_url => 'http://localhost:9999',
53           );
54
55       This attribute is used for REST requests. You should set it to where
56       the MetaCPAN is accessible. By default it's already set correctly, but
57       if you're running a local instance of MetaCPAN, or use a local mirror,
58       or tunnel it through a local port, or any of those stuff, you would
59       want to change this.
60
61       Default: https://fastapi.metacpan.org/v1.
62
63       This attribute is read-only (immutable), meaning that once it's set on
64       initialize (via "new()"), you cannot change it. If you need to, create
65       a new instance of MetaCPAN::API. Why is it immutable? Because it's
66       better.
67
68   ua
69       This attribute is used to contain the user agent used for running the
70       REST request to the server. It is specifically set to HTTP::Tiny, so if
71       you want to set it manually, make sure it's of HTTP::Tiny.
72
73       HTTP::Tiny is used as part of the philosophy of keeping it tiny.
74
75       This attribute is read-only (immutable), meaning that once it's set on
76       initialize (via "new()"), you cannot change it. If you need to, create
77       a new instance of MetaCPAN::API. Why is it immutable? Because it's
78       better.
79
80   ua_args
81           my $mcpan = MetaCPAN::API->new(
82               ua_args => [ agent => 'MyAgent' ],
83           );
84
85       The arguments that will be given to the HTTP::Tiny user agent.
86
87       This attribute is read-only (immutable), meaning that once it's set on
88       initialize (via "new()"), you cannot change it. If you need to, create
89       a new instance of MetaCPAN::API. Why is it immutable? Because it's
90       better.
91
92       The default is a user agent string: MetaCPAN::API/$version.
93

METHODS

95   fetch
96           my $result = $mcpan->fetch('/release/distribution/Moose');
97
98           # with parameters
99           my $more = $mcpan->fetch(
100               '/release/distribution/Moose',
101               param => 'value',
102           );
103
104       This is a helper method for API implementations. It fetches a path from
105       MetaCPAN, decodes the JSON from the content variable and returns it.
106
107       You don't really need to use it, but you can in case you want to write
108       your own extension implementation to MetaCPAN::API.
109
110       It accepts an additional hash as "GET" parameters.
111
112   post
113           # /release&content={"query":{"match_all":{}},"filter":{"prefix":{"archive":"Cache-Cache-1.06"}}}
114           my $result = $mcpan->post(
115               'release',
116               {
117                   query  => { match_all => {} },
118                   filter => { prefix => { archive => 'Cache-Cache-1.06' } },
119               },
120           );
121
122       The POST equivalent of the "fetch()" method. It gets the path and JSON
123       request.
124

AUTHOR

126       Sawyer X <xsawyerx@cpan.org>
127
129       This software is copyright (c) 2011 by Sawyer X.
130
131       This is free software; you can redistribute it and/or modify it under
132       the same terms as the Perl 5 programming language system itself.
133
134
135
136perl v5.32.1                      2021-01-27                  MetaCPAN::API(3)
Impressum