WebService::Geograph::API - Perl interface to the Geograph.co.uk API
use WebService::Geograph::API; my $api = new WebService::Geograph::API ( { 'key' => 'your_api_key_here'} ) ; my $rv = $api->lookup ( 'csv', { 'i' => 12345, 'll' => 1, 'thumb' => 1, }) ; my $data = $rd->{results} ;
This module provides a simple interface to using the geograph.co.uk API service.
The actual core class, WebService::Geograph::API is a subclass of LWP::UserAgent so all the usual parameters apply.
WebService::Geograph::API
LWP::UserAgent
new
The following constructing method creates a new WebService::Geograph::API object and returns it. It accepts a single parameter, key, which is the API key for the service. You must obtain a valid key otherwise you will not be able to use the API.
Obtaining a key is free. See : http://www.geograph.org.uk/help/api#api for more information.
my $api = new WebService::Geograph::API ( { 'key' => 'your_api_key_here'} ) ;
lookup
Creates a new WebService::Geograph::Request object and executes it.
WebService::Geograph::Request
my $rv = $api->lookup ( 'csv', { 'i' => 12345, 'll' => 1, } ) ; or my $rv = $api->lookup ( 'search ', { q = 'W12 8JL' } ) ;
Valid modes at the moment include csv for exporting CSV and search for creating custom searches and obtaining their 'i' number. A very good and detailed overview of the various parameters they support can be find on the API page located at : http://www.geograph.org.uk/help/api#api
This method creates and returns a new WebService::Geograph::Response object. The object is a standard HTTP::Response object with some additional fields. If no errors occur, the results of the query will be located inside results ;
WebService::Geograph::Response
HTTP::Response
my $data = $rv->{results} ;
execute_request
Internal method that executes a request and blesses the response into a WebService::Geograph::Response object.
create_results_node
Intenal method which assigns the actual data returned from the API within the response objects 'results' key.
Please feel free to send any bug reports and suggestions to my email listed below.
For more information and useless facts on my life, you can also check my blog:
http://idaru.blogspot.com/
Spiros Denaxas CPAN ID: SDEN Lokku Ltd ( http://www.nestoria.co.uk ) s [dot] denaxas [@] gmail [dot]com
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
WebService::Geograph::Request, WebService::Geograph::Response, http://www.geograph.co.uk, http://www.geograph.org.uk/help/api#api
To install WebService::Geograph::API, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WebService::Geograph::API
CPAN shell
perl -MCPAN -e shell install WebService::Geograph::API
For more information on module installation, please visit the detailed CPAN module installation guide.