Wednesday, October 19, 2005

Tagyu Perl API

Introduction

Tagyu is a service that can suggest you tags relevant to your content. They have a REST interface available so I quickly rolled up a simple Perl wrapper over it.

Simple to use

Using Tagyu Web Service from Perl is now very simple and all you need to do is:

use Tagyu::Search;

my @tags = Tagyu::Search->SuggestTags("[PUT YOUR TEXT HERE]");

SuggestTags method returns an array of strings containing the tags received from Tagyu for the specified text using its REST API.

Passing options

You can also specify options to the SuggestTags method of Tagyu::Search module as key-value pairs to modify its behavior when it dispatches requests to the Tagyu.com servers. Here's an example that sets the timeout parameter.

my @tags = Tagyu::Search->SuggestTags("[PUT YOUR TEXT HERE]",
(timeout => 600)
);
Tagyu::Search uses LWP::UserAgent behind the scenes. So for details of all supported options and their default values, please check the documentation of LWP::UserAgent's constructor.

Supports HTTP Basic Authentication

Tagyu imposes a limit of one request per minute from a single IP address and requests beyond this limit result in an error. However registered users have a soft cap of 1000 requests per day. Tagyu::Search package allows you to pass your username/password to Tagyu in the following manner:

# Instantiate a new Tagyu::Search object.
my $tagyu = Tagyu::Search->new(
username => "[YOUR-USERNAME]",
password => "[YOUR-PASSWORD]"
);

# Invoke the SuggestTags method on the Tagyu::Search object.
my @tags = $tagyu->SuggestTags("[YOUR-TEXT]");
You can register at Tagyu here.

Downloads

Need Ideas?

For some ideas on what you can do with Tagyu::Search, have a look here.

Comments and suggestions are welcome

Before posting my module to CPAN I have sent an RFC for my Perl module on comp.lang.perl.modules USENET group. So download the latest relase of Tagyu::Search and give it a try. Please share your feedback! Thanks.