RDF::Q...Client(3pm)
π RDF::Query::Client π
okay so bestie, welcome to the RDF::Query::Client(3pm) page β a User Contributed Perl Documentation classic, and honestly? it's giving β¨*go get data from W3C SPARQL Protocol 1.0 servers*β¨. that's the whole NAME energy right there. let's get into it π¦
πΈ SYNOPSIS πΈ
use RDF::Query::Client;
my $query = RDF::Query::Client
->new('SELECT DISTINCT ?s WHERE { ?s ?p ?o . }');
my $iterator = $query->execute('http://example.com/sparql');
while (my $row = $iterator->next) {
print $row->{s}->as_string;
}
look at her go. four lines and you're pulling data off the whole entire web. main character behavior fr fr π
β¨ DESCRIPTION β¨
π Constructor
new ( $sparql, \%opts )β hands you back a brand newRDF::Query::Clientobject for the$sparqlyou passed in. and here's the tea: its interface is designed to be roughly compatible withRDF::Queryobjects, even thoughRDF::Queryisn't actually required by this module. so like, similar vibe, different source, iykyk π«
Options include:
UserAgentβ anLWP::UserAgentto handle the HTTP requests. π«Ά
now the important bit: unlike RDF::Query, where you get a whole choice of query language, the query language for RDF::Query::Client is always 'sparql'. no options, no debate, it's a one-language household. but β RDF::TrineShortcuts does offer a way to perform RDQL queries on remote SPARQL stores (by transforming RDQL to SPARQL). so there's a loophole, bestie π
π Public Methods
execute ( $endpoint, \%opts )β$endpointis a URI object or a string holding the endpoint URI you wanna query. go off.
Options include:
UserAgentβ anLWP::UserAgentto handle HTTP requests. π§QueryMethodβ'GET','POST','PATCH'orundef(automatic). πQueryParameterβ defaults to'query'.AuthUsernameβ HTTP Basic authorization.AuthPasswordβ HTTP Basic authorization.Headersβ additional headers to include (hashref).Parametersβ additional GET/POST fields to include (hashref).ContentTypeβ'application/sparql-query','application/sparql-update'or'application/x-www-form-urlencoded'(default).
and the returns?? iconic, honestly:
- returns
undefon error π - returns an
RDF::Trine::Iteratorif called in scalar context - returns an array obtained by calling
get_allon the iterator if called in list context
discover_execute( $resource_uri, \%opts )β β οΈ experimental feature, bestie, proceed with the awareness β οΈ it discovers a SPARQL endpoint relevant to$resource_uriand then calls$query->executeagainst that. it uses an LRDD-like method to discover the endpoint. so if you're publishing data and you want people to be able to find your SPARQL endpoint automatically? the easiest way is to include aLinkheader in HTTP responses:
Link: </my/endpoint>; rel="http://ontologi.es/sparql#endpoint"
change the URL in the angled brackets, but not the URL in the rel string. do not touch the rel string. hands off the rel string. π
π¨ this feature requires the HTTP::LRDD package to be installed. no package, no discovery, periodt.
get ( $endpoint, \%opts )β executes the query using the specified endpoint, and returns the first matching row as a LIST of values. takes the same arguments asexecute. πas_sparqlβ returns the query as a string in the SPARQL syntax. πuseragentβ returns theLWP::UserAgentobject used for retrieving web content.http_responseβ returns the last HTTP Response the client experienced. π‘errorβ returns the last error the client experienced. π
π Security
the execute and get methods let you pass AuthUsername and AuthPassword options to them for HTTP Basic authentication. basic, but it works.
for more complicated authentication (Digest, OAuth, Windows, etc), it's also possible to pass these methods a customised LWP::UserAgent. you're not stuck, bestie, you just gotta bring your own agent π«Ά
if you have the Crypt::SSLeay package installed, requests to HTTPS endpoints should work. it's possible to specify a client X.509 certificate (e.g. for WebID authentication) by setting particular environment variables. see the Crypt::SSLeay documentation for details. π
π BUGS π
Probably.
like, probably probably. that's the whole section. she said what she said π
please report any you find here: <https://rt.cpan.org/Dist/Display.html?Queue=RDF-Query-Client>.
π SEE ALSO π
RDF::Trine,RDF::Trine::IteratorRDF::QueryLWP::UserAgent- <http://www.w3.org/TR/rdf-sparql-protocol/>
- <http://www.w3.org/TR/rdf-sparql-query/>
- <http://www.perlrdf.org/>
π« AUTHOR π«
Toby Inkster, <tobyink@cpan.org>
π COPYRIGHT AND LICENSE π
Copyright (C) 2009-2013 by Toby Inkster
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
β DISCLAIMER OF WARRANTIES β
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
translation: no promises, no cap. use it, love it, but nobody's guaranteeing anything π
and that's the whole page, bestie!! this one shipped as perl v5.28.1, dated 2019-02-07, and it's the RDF::Q...Client(3pm) you know and love. go query something iconic, you absolute legend π¦β¨π
π¦ where this page comes from
- debian bookworm: librdf-query-client-perl 0.114-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: librdf-query-client-perl 0.114-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: librdf-query-client-perl 0.114-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: librdf-query-client-perl 0.114-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms