Module:SPARQL

From TITAF TANGOWIKI
Revision as of 22:41, 21 March 2025 by Donxello (talk | contribs)

Documentation for this module may be created at Module:SPARQL/doc

local http = require("socket.http")

local p = {}

function p.fetchData(frame)
    local sparqlQuery = frame.args[1]
    local url = "https://query.wikidata.org/sparql?query=" .. mw.uri.encode(sparqlQuery, "PATH")

    local body, code, headers = http.request(url)

    if code == 200 then
        return body
    else
        return "Error: HTTP " .. (code or "unknown")
    end
end

return p