{"id":13481679,"url":"https://github.com/zazuko/d3-sparql","last_synced_at":"2025-04-15T02:09:20.059Z","repository":{"id":42596814,"uuid":"98034019","full_name":"zazuko/d3-sparql","owner":"zazuko","description":"Query a SPARQL endpoint with a SELECT query and get the data ready to be used with d3js","archived":false,"fork":false,"pushed_at":"2019-05-10T08:00:54.000Z","size":104,"stargazers_count":118,"open_issues_count":3,"forks_count":11,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-15T02:09:14.365Z","etag":null,"topics":["d3js","json","rdf","sparql","triplestore"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zazuko.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-22T13:45:55.000Z","updated_at":"2025-04-14T18:37:52.000Z","dependencies_parsed_at":"2022-07-09T15:37:01.490Z","dependency_job_id":null,"html_url":"https://github.com/zazuko/d3-sparql","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zazuko%2Fd3-sparql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zazuko%2Fd3-sparql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zazuko%2Fd3-sparql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zazuko%2Fd3-sparql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zazuko","download_url":"https://codeload.github.com/zazuko/d3-sparql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248991544,"owners_count":21194894,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["d3js","json","rdf","sparql","triplestore"],"created_at":"2024-07-31T17:00:54.100Z","updated_at":"2025-04-15T02:09:20.041Z","avatar_url":"https://github.com/zazuko.png","language":"JavaScript","funding_links":[],"categories":["Utils","Visualization"],"sub_categories":["BBedit"],"readme":"# d3-sparql\n\nThis module lets you request data from [SPARQL](https://www.w3.org/TR/sparql11-query/) [endpoints](https://www.w3.org/wiki/SparqlEndpoints) in the vein of [d3-csv](https://github.com/d3/d3-dsv) and friends. It is generating a JSON structure from SPARQL query results, you can use that in any way you like in your code, with or without D3.\n\nThe access through a SPARQL endpoint allows a faster and more efficient data preparation (once you got [the hang of SPARQL and the RDF data model](https://www.youtube.com/watch?v=FvGndkpa4K0)). Ultimately it keeps visualizations up to date. Think of SPARQL endpoints as the most flexible API imaginable.\n\nDefine the SPARQL query and endpoint:\n\n```js\n// Author of Q3011087 (D3.js)\nvar mikeQuery = `SELECT ?developerName WHERE {\n  wd:Q3011087 wdt:P178 ?developer.\n  ?developer rdfs:label ?developerName.\n  FILTER(LANG(?developerName) = 'en')\n}`\n\nwikidataUrl = 'https://query.wikidata.org/bigdata/namespace/wdq/sparql'\n```\n\nTo query the endpoint and get the result:\n\n```js\nd3.sparql(wikidataUrl, mikeQuery).then((data) =\u003e {\n  console.log(data); // [{'developerName': 'Mike Bostock'}]\n})\n```\n\nMore [examples](https://github.com/zazuko/d3-sparql/tree/master/examples) are provided in the [repository](https://github.com/zazuko/d3-sparql).\n\n## Features\n\n- Transformation of [XSD Datatypes](https://www.w3.org/2011/rdf-wg/wiki/XSD_Datatypes) (e.g. `xsd:dateTime`, `xsd:boolean`, ...) to native JavaScript types.\n- Reformatting of the JSON Structure to a d3 style layout while using the provided variables names of the SPARQL Query.\n\n## Limitations\n\n- Only `SELECT` queries are supported. (This provides a projection of the graph data onto a table structure used by d3.)\n- Currently only supports endpoints which are able to respond with `application/sparql-results+json`.\n\n## Installing\n\nUsing NPM: `npm install d3-sparql`. You can also use a CDN, for instance \u003chttps://www.jsdelivr.com\u003e.\n\nSee [CHANGELOG](CHANGELOG.md) for details about available versions.\n\n## API Reference\n\nThis package adds a `sparql` function to the global `d3` object: `d3.sparql(endpoint, query, options = {})`.\n\n\u003ca name=\"request\" href=\"#sparql\"\u003e#\u003c/a\u003e d3.\u003cb\u003e sparql \u003c/b\u003e(\u003ci\u003eendpoint\u003c/i\u003e, \u003ci\u003equery\u003c/i\u003e[, \u003ci\u003eoptions = {}\u003c/i\u003e]) [\u003c\u003e](https://github.com/zazuko/d3-sparql/blob/master/src/sparql.js#L8 \"Source\")\n\n`options` is an optional object that will get merged with the second argument of [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch).\n\n```js\nd3.sparql(endpoint, query)\n  .then((data) =\u003e …);\n```\n\n## Acknowledgement\nThe initial development of this library by [Zazuko](http://www.zazuko.com) was supported by the [City of Zürich](https://www.stadt-zuerich.ch/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzazuko%2Fd3-sparql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzazuko%2Fd3-sparql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzazuko%2Fd3-sparql/lists"}