NAME

WWW::AfinimaKi - AfinimaKi Recommendation Engine Client

SYNOPSIS

use WWW::AfinimaKi;         # Notice the uppercase "K"!

my $api = WWW::AfinimaKi->new( $your_api_key, $your_api_secret);

...

$api->set_rate($user_id, $item_id, $rate);

...

my $estimated_rate = $api->estimate_rate($user_id, $rate);

...

my $recommendations = $api->get_recommendations($user_id);
foreach (@$recommendations) {
    print "item_id: $_->{item_id} estimated_rate: $_->{estimated_rate}\n";
}

DESCRIPTION

WWW::AfinimaKi is a simple client for the AfinimaKi Recommendation API. Check http://www.afinimaki.com/api for more details.

Methods

new

my $api = WWW::AfinimaKi->new( 
                api_key     => $your_api_key, 
                api_secret  => $your_api_secret, 
                debug       => $debug_level,
);

if (!$api) {
    die "Error construction afinimaki, wrong keys length?";
}

new Construct the AfinimaKi object. No nework traffic is generated (the account credentialas are not checked at this point). 

The given keys must be 32 character long. You can get them at afinimaki.com. Debug level can be 0 or 1.

user-item services

set_rate

$api->set_rate($user_id, $item_id, $rate);

Stores a rate in the server. Waits until the call has ended.

On error, returns undef, and carp the RPC::XML error.

estimate_rate

my $estimated_rate = $api->estimate_rate($user_id, $item_id);

Estimate a rate. Undef is returned if the rate could not be estimated (usually because the given user or the given item does not have many rates).

On error, returns undef, and carp the RPC::XML error.

estimate_multiple_rates

my $rates_hashref = $api->estimate_rate($user_id, @item_ids);
    foreach my $item_id (keys %$rates_hashref) {
    print "Estimated rate for $item_id is $rates_hashref->{$item_id}\n";
}

Estimate multimple rates. The returned hash has the structure: 
        item_id => estimated_rate

On error, returns undef, and carp the RPC::XML error.

get_recommendations

my $recommendations = $api->get_recommendations($user_id);

foreach (@$recommendations) {
    print "item_id: $_->{item_id} estimated_rate: $_->{estimated_rate}\n";
}

Get a list of user's recommentations, based on users' and community previous rates.
Recommendations does not include rated or marked items (in the whish or black list).

add_to_wishlist

$api->add_to_wishlist($user_id, $item_id);

The given $item_id will be added do user's wishlist. This means that id will not
be in the user's recommentation list anymore, and the action will be use to tune users's recommendations (The user seems to like this item).

add_to_blacklist

$api->add_to_blacklist($user_id, $item_id);

The given $item_id will be added do user's blacklist. This means that id will not
be in the user's recommentation list anymore, and the action will be use to tune users's recommendations (The user seems to dislike this item). 

remove_from_lists

$api->remove_from_lists($user_id, $item_id);

Remove the given item from user's wish and black lists, and also removes user item's rating (if any).

user-user services

get_user_user_afinimaki

my $afinimaki = $api->get_user_user_afinimaki($user_id_1, $user_id_2);

Gets user vs user afinimaki. AfinimaKi range is [0.0-1.0].

get_soul_mates

my $soul_mates = $api->get_soul_mates($user_id);

foreach (@$soul_mates) {
    print "user_id: $_->{user_id} afinimaki: $_->{afinimaki}\n";
}

Get a list of user's soul mates (users with similar tastes). AfinimaKi range is [0.0-1.0].

AUTHORS

WWW::AfinimaKi by Matias Alejo Garcia (matiu at cpan.org)

COPYRIGHT

Copyright (c) 2010 Matias Alejo Garcia. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SUPPORT / WARRANTY

The WWW::AfinimaKi is free Open Source software. IT COMES WITHOUT WARRANTY OF ANY KIND.

Github repository is at http://github.com/matiu/WWW--AfinimaKi

BUGS

None discovered yet... please let me know if you run into one.