;; Example query to wikidata listing cats (use-modules (sparql driver) (ice-9 receive) (ice-9 rdelim) (web response)) (define q (sparql-query " SELECT ?item WHERE { ?item wdt:P31 wd:Q146. } LIMIT 10 " #:uri "https://query.wikidata.org/sparql" #:type "text/csv" #:store-backend 'blazegraph)) (display q) (receive (header port) ;; Note: "text/csv" is the only format that is consistent for multiple SPARQL back-ends (Virtuoso, BlazeGraph, ...) q (if (= (response-code header) 200) ; This means the query went OK. (call-some-function port) #f)) ; Deal with errors at the #f. (define (call-some-function port) (let ((line (read-line port))) (if (eof-object? line) #t (begin (format #t "Line: ~a~%" line) ;; Tail-recurse until we have processed each line. (call-some-function port)))))