Reddit API for Perl

I have completed the meat of a reasonably complete API wrapper for Reddit. You can grab it at

It is pretty simple to use, and the docs are complete, but here is the gist:

use Reddit::API;

my $session_file = '~/.reddit';
my $reddit       = Reddit::API->new(session_file => $session_file);

unless ($reddit->is_logged_in) {
    $reddit->login('someone', 'secret');

    subreddit => 'perl',
    title     => 'Perl is still alive!',
    url       => ''

my $links = $reddit->fetch_links(subreddit => '/r/perl', limit => 10);
foreach (@{$links->{items}}) {


Consider renaming to WebService::Reddit instead. The use of API in the module name is discouraged:

The use of new top-level namespaces is also discouraged when existing ones will suffice: . That's why I suggested using WebService.

I'm a little confused as to how you are supposed to interact with retrieved links:

my $links = $reddit->fetch_links(subreddit => '/r/perl', limit => 10);
foreach my $current_link (@{$links->{items}}) {
    print $current_link->{'title'} ."\n";

That generates a whole bunch of warnings before printing the titles:

Field distinguished is missing from package Reddit::Client::Link
 at /usr/local/share/perl/5.12.4/Reddit/ line 403

Am I doing it wrong?

Also, installation from cpan consistently fails, FYI. :)

Any idea how i can get around this ?

Attempt to access disallowed key 'over_18' in a restricted hash at /usr/local/lib/perl5/site_perl/5.10.1/Reddit/Client/ line 56.

i've tried setting
use fields qw/over_18/;
with no success .. I blindly tried that without really understanding what it does ( sorry about that )


and thank you for the doc

Leave a comment

About Jeff Ober

user-pic I am a software developer for Cox Media Group, writing Python for cash and Perl for fun.