Skip to main content
1 of 6
gideon
  • 207
  • 1
  • 8

Net::StackExchange2 - Perl Wrapper for StackExchange API (it's on CPAN)

##About

This library is a little labour of love for two things dear to me : StackOverflow, a place where I've learned just so much, and Perl a cryptic language that's giving me perspective. The whole thing was a learning project, so any feedback and kind-insults are welcome. Please file them as issues on the github repository.

##Examples

The API is designed to be a one to one mapping with the methods in the documentation. It also has some conventions.

use Net::StackExchange2;
#For read-only methods.
my $se = Net::StackExchange2->new({site => 'stackoverflow'});
 
#OR
 
#for methods that require auth.
my $se = Net::StackExchange2->new(
    {site=>"stackoverflow", 
     access_token => '<THE ACCESS TOKEN>', 
     key => '<YOUR APP KEY>'
    }
);
 
my $ret =  $se->answers->answers_all({ order=> "desc", sort=>"votes" });
my $ret = $se->answers->answers(14586834);#pass one single ID
#or pass many in an array ref
my $ret = $se->answers->answers([4449779, 4477003]);
 
my $ret  = $se->search->search({tagged=>"perl"});
 
my $ret = $se->tags->tags_top_askers("perl", "month");
 
#filters are also supported. 
 
#This method gets comments from one user to another 
#and only retrives the body of the comment
my $ret = $se->users->
       users_comments_toid(368070,22656, {filter => '!mRNaB_KjjP'});

###License

The library is licensed under the Bsd 3-clause. See this for a quick english TL:DR about it.

###Download

Ideally you don't need to download anything to use it with perl. It's on CPAN here. You just install it with cpan. Note it's Net:StackExchange2 (2 at the end). Net:StackExchange is an older distribution for the 1.x API.

sudo cpan
>install Net::StackExchange2

##Contact

Contact me at gideon [at] cpan [dot] org for any issues with this distribution.

##Code

All of it is written in perl of course. Since I'm a beginner it might not be the best perl you've seen, I would be very happy to hear any suggestions/feedback.

The project is on github here: https://github.com/gideondsouza/perl-net-stackexchange

Please file any issues/bugs/features on the github page.

gideon
  • 207
  • 1
  • 8