Games-EveOnline-API
view release on metacpan or search on metacpan
lib/Games/EveOnline/API.pm view on Meta::CPAN
This module is no longer being maintained as the XML API is no more.
=head1 DESCRIPTION
This module provides a Perl wrapper around the Eve-Online API, version 2.
The need for the wrapper arrises for two reasons. First, the XML that
is provided by the API is overly complex, at least for my taste. So, other
than just returning you a perl data representation of the XML, it also
simplifies the results.
Only a couple of the methods provided by this module can be used straight
away. The rest require that you get a user_id (keyID) and api_key (vCode).
=head1 A NOTE ON CACHING
Most of these methods return a 'cached_until' value. I've no clue if this
is CCP telling you how long you should cache the information before you
should request it again, or if this is the point at which CCP will refresh
their cache of this information.
Either way, it is good etiquet to follow the cacheing guidelines of a
provider. If you over-use the API I'm sure you'll eventually get blocked.
=cut
use Types::Standard qw( Int Str );
use Type::Utils qw( class_type );
use URI;
use LWP::UserAgent qw();
use XML::Simple qw();
use Carp qw( croak );
=head1 ARGUMENTS
=head2 user_id
An Eve Online API user ID (also known as a keyID).
=head2 api_key
The key, as provided Eve Online, to access the API (also known
as a vCode).
=head2 character_id
Set the default C<character_id>. Any methods that require
a characte ID, and are not given one, will use this one.
=head2 api_url
The URL that will be used to access the Eve Online API.
Defaults to L<https://api.eveonline.com>. Normally you
won't want to change this.
=head2 ua
The underlying L<LWP::UserAgent> object. Default to a new one
with no special arguments. Override this if you want to, for
example, enable keepalive or an HTTP proxy.
=cut
has user_id => (is=>'ro', isa=>Int );
has api_key => (is=>'ro', isa=>Str );
has character_id => (is=>'ro', isa=>Int );
has api_url => (is=>'ro', isa=>Str, default=>'https://api.eveonline.com');
has ua => (is=>'lazy', isa=>class_type('LWP::UserAgent'));
sub _build_ua {
return LWP::UserAgent->new;
}
=head1 ANONYMOUS METHODS
These methods may be called anonymously, without authentication.
=head2 skill_tree
my $skill_groups = $eapi->skill_tree();
Returns a complex data structure containing the entire skill tree.
The data structure is:
{
cached_until => $date_time,
$group_id => {
name => $group_name,
skills => {
$skill_id => {
name => $skill_name,
description => $skill_description,
rank => $skill_rank,
primary_attribute => $skill_primary_attribute,
secondary_attribute => $skill_secondary_attribute,
bonuses => {
$bonus_name => $bonus_value,
},
required_skills => {
$skill_id => $skill_level,
},
}
}
}
}
=cut
sub skill_tree {
my ($self) = @_;
my $data = $self->_load_xml(
path => 'eve/SkillTree.xml.aspx',
);
my $result = {};
return $self->_get_error( $data ) if defined $data->{error};
my $group_rows = $data->{result}->{rowset}->{row};
( run in 1.722 second using v1.01-cache-2.11-cpan-39bf76dae61 )