API

JSON

\&query=" ~ $encoded ); if $response { return $response; } else { X::Wikidata::API.new( error => "Error response " ~ $response ~ ": " ~ $response ).throw; } }

NAME

Wikidata::API - Query the Wikidata API

SYNOPSIS

use Wikidata::API;
my $query = q:to/END/;
SELECT ?person ?personLabel WHERE {
?person wdt:P69 wd:Q1232180 . 
    ?person wdt:P21 wd:Q6581072 . 
SERVICE wikibase:label { 
      bd:serviceParam wikibase:language "en" .
    }
} ORDER BY ?personLabel
END
my $UGR-women = query( $query );
my $to-file= q:to/END/;
SELECT ?person ?personLabel ?occupation ?occupationLabel WHERE {
  ?person wdt:P69 wd:Q1232180. 
  ?person wdt:P21 wd:Q6581072.
  ?person wdt:P106 ?occupation
  SERVICE wikibase:label {				
    bd:serviceParam wikibase:language "es" .
  }
}
END
spurt "ugr-women-by-job.sparql", $to-file;
  say query-file( $to-file );

DESCRIPTION

This is a convenience wrapper for the SPARQL endpoints of Wikidata, found at https://query.wikidata.org/. You can either query directly using SPARQL (check out examples here: https://www.mediawiki.org/wiki/Special:MyLanguage/Wikidata_query_service) or crafting a file and sending it.

=over 4

  • query( Str $query)

Passes to the Wikidata API the SPARQL query, returns a data structure which includes results with the rests of results

  • query-file( Str $query)

Opens the file and passes it to query to make the request.

=cut

AUTHOR

JJ Merelo <[email protected]>

COPYRIGHT AND LICENSE

Copyright 2017 JJ Merelo

This library is free software; you can redistribute it and/or modify it under the GPL 3.0.

Wikidata::API v0.0.5

A thin wrapper for querying the Wikidata API using SPARQL

Authors

  • JJ Merelo

License

GPL-3.0

Dependencies

URI::EncodeWWWJSON::Tiny

Test Dependencies

Provides

  • Wikidata::API
  • X::Wikidata::API

Documentation

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.