How to create a new Catmandu importer

By Vitali Peil

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.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s