NAME
WebService::HackerNews - interface to the official HackerNews API
SYNOPSIS
use WebService::HackerNews;
my $hn = WebService::HackerNews->new;
my @top100 = $hn->top_story_ids;
my $item = $hn->item( $top100[0] );
printf qq{"%s" by %s (karma: %d)\n},
$item->title, $item->by, $user->karma;
DESCRIPTION
This module provides an interface to the official Hacker News API. This is very much a lash-up at the moment, and liable to change. Feel free to hack on it and send me pull requests.
METHODS
Most of the methods in the official doc are implemented.
top_story_ids
Returns a list of ids for the current top 100 stories.
my @ids = $hn->top_story_ids;
You can then call item()
to get the details for specific items.
item($ID)
Takes an item id and returns an instance of WebService::HackerNews::Item, which has attributes named exactly the same as the properties listed in the official doc.
$item = $hn->item($id);
printf "item %d has type %s\n", $item->id, $item->type;
user($ID)
Takes a user id and returns an instance of WebService::HackerNews::User, which has attributes named exactly the same as the user properties listed in the official doc.
$user = $hn->user($username);
printf "user %s has %d karma\n", $user->id, $user->karma;
max_item_id
Returns the max item id.
SEE ALSO
REPOSITORY
https://github.com/neilbowers/WebService-HackerNews
AUTHOR
Neil Bowers <neilb@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Neil Bowers <neilb@cpan.org>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.