A javaScript API for MetaCPAN.
Right now, this is still a proof of concept and will grow, but...
<html>
<head>
<script type="text/javascript" src="jquery.js" ></script>
<script type="text/javascript" src="metacpan.js"></script>
</head>
<body>
<script type="text/javascript">
$(function(){
var metacpan = $.metacpan();
// returns a promise, just like $.get()
metacpan.author('YANICK').success(function(data){
alert( data.name );
});
metacpan.module('Dist::Zilla').success(function(data){
alert( data.description );
});
metacpan.release('Dist-Zilla').success(function(data){
alert( data.date );
});
</script>
</body>
</html>
Note: All methods return promises, just like jQuery's AJAX methods, and not the queries data directly.
Returns information about the given author (see http://api.metacpan.org/v0/author/_mapping).
$.metacpan().author('YANICK').success( function(data){
alert( data.name );
});
Returns information about the given module (see http://api.metacpan.org/v0/module/_mapping).
$.metacpan().module('Dist::Zilla').success( function(data){
alert( data.description );
});
Returns information about the given release (see http://api.metacpan.org/v0/release/_mapping).
$.metacpan().release('Dist-Zilla').success( function(data){
alert( data.date );
});
Returns information about the given file (see http://api.metacpan.org/v0/file/_mapping).
$.metacpan().file('DOY','Moose-2.0001','lib/Moose.pm').success( function(data){
alert( data.distribution );
});
-
The MetaCPAN API documentation, natch.
-
The MetaCPAN explorer, which provides an easy wayt to play with the requests (alongside good examples).
-
MetaCPAN::API, providing an interface to the MetaCPAN API in perl-space.