How to create a new Catmandu importer

08 November 2013 by Vitali

Within the Catmandu framework different kinds of importers have been implemented

Since Catmandu is designed for in a way, that can be extended… So in this little Tutorial we are going to create our own importer module Catmandu::Importer::EuroPMC.

Starting with a module

First of all, let us remember that

1. importers have to be within the namespace *Catmandu::Importer::*
2. Catmandu uses *Module::Build* as building tool
$ cpanm Module::Build Module::Starter
$ module-starter --builder="Module::Build" --module=Catmandu::Importer::EuroPMC --author="Vitali" /
-- email=""

Now, change directory to Catmandu-Importer-EuroPMC and open the file lib/Catmandu/Importer/

Structure of an importer module

package Catmandu::Importer::EuroPMC;

use Catmandu::Sane;
use Moo;

with 'Catmandu::Importer';

use constant BASE_URL => '';

has base => (is => 'ro', default => sub { return BASE_URL; });
has source => (is => 'ro', default => sub { return "MED"; });
has query => (is => 'ro', required => 1);

# public method
sub generator {
	my ($self) = @_;
	my $request = $self->base . "/" . $self->source . "/" . $self->query;
	# perform get request ....

	return $hashref;


More insights in Catmandu will be dicussed in later posts.

comments powered by Disqus