RDF::Q...Client(3pm)

πŸ“¦
version 0.114 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– 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 new RDF::Query::Client object for the $sparql you passed in. and here's the tea: its interface is designed to be roughly compatible with RDF::Query objects, even though RDF::Query isn't actually required by this module. so like, similar vibe, different source, iykyk πŸ’«

Options include:

  • UserAgent β€” an LWP::UserAgent to 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 ) β€” $endpoint is a URI object or a string holding the endpoint URI you wanna query. go off.

Options include:

  • UserAgent β€” an LWP::UserAgent to handle HTTP requests. 🧚
  • QueryMethod β€” 'GET', 'POST', 'PATCH' or undef (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 undef on error 😭
  • returns an RDF::Trine::Iterator if called in scalar context
  • returns an array obtained by calling get_all on 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_uri and then calls $query->execute against 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 a Link header 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 as execute. πŸ’œ
  • as_sparql β€” returns the query as a string in the SPARQL syntax. 🌟
  • useragent β€” returns the LWP::UserAgent object 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 🌈


πŸ’« AUTHOR πŸ’«

Toby Inkster, <tobyink@cpan.org>


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