NAME

Metaweb - Perl interface to the Metaweb/Freebase API

VERSION

Version 0.01

SYNOPSIS

use Metaweb;

my $mw = Metaweb->new({
    username => $username,
    password => $password
});
$mw->login();
my $result = $mw->query($mql);

DESCRIPTION

This is a Perl interface to the Metaweb database, best known through the application Freebase (http://freebase.com). Freebase is currently in alpha release, with world-readable data but requiring an invitation and login to be able to update/write data.

This module is very much alpha code. It has lots of stuff not implemented and will undergo significant changes. Breakage may occur between versions, so consider yourself warned.

new

Instantiate a Metaweb client object. Takes various options including:

username

The username to login with

password

The password to login with

username()

Get/set default login username.

password()

Get/set default login password.

server()

Get/set server to login to. Defaults to 'http://www.freebase.com'.

login_url()

Get/set the URL to login to, relative to the server. Defaults to '/api/account/login'.

query_url()

Get/set the URL to perform queries, relative to the server. Defaults to '/api/service/mqlread'.

login()

Perform a login to the Metaweb server and pick up the necessary cookie. Optionally takes a hashref of arguments including username, password, server, and login_url which will be used only for this login and not set on the object. (Generally you'll want to set those details when you create the metaweb object.)

query()

Perform a MQL query. Takes a query as a Perl data structure that's converted to JSON using the JSON module's objToJson() method. The MQL envelope will automatically be put around the query.

json_query

Like query() only it accepts and returns JSON, without converting to/from Perl. The expected JSON format is more or less everything that follows "query:" in the MQL, i.e.:

my $json_query = q({
    "type":"/music/artist",
    "name":"The Police",
    "album":[]
});

raw_result() is still set as a side effect, but error() is *not* set, as we'd need to parse the JSON to get at it and the whole point of this is that it's unparsed.

raw_result()

The raw JSON from the response. This is set by both query() and json_query().

err_code()

Set on error by query(). json_query() doesn't set this; you need to parse the JSON yourself.

err_message()

Set on error by query(). json_query() doesn't set this; you need to parse the JSON yourself.

AUTHOR

Kirrily Robert, <skud at cpan.og>

BUGS

Please report any bugs or feature requests to bug-metaweb at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Metaweb. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Metaweb

You can also look for information at:

ACKNOWLEDGEMENTS

Thanks to the following people with whom I have discussed Metaweb Perl APIs recently...

Hayden Stainsby (CPAN: HDS)
Kirsten Jones (CPAN: SYNEDRA)

COPYRIGHT & LICENSE

Copyright 2007 Kirrily Robert, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.