All Projects → RubenVerborgh → Sparql.js

RubenVerborgh / Sparql.js

Licence: other
A parser for the SPARQL query language in JavaScript

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Sparql.js

Rdflib
RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information.
Stars: ✭ 1,584 (+484.5%)
Mutual labels:  rdf, serializer, parser
Serd
A lightweight C library for RDF syntax
Stars: ✭ 43 (-84.13%)
Mutual labels:  rdf, serializer, parser
N3.js
Lightning fast, spec-compatible, streaming RDF for JavaScript
Stars: ✭ 521 (+92.25%)
Mutual labels:  rdf, serializer, parser
Rdflib Jsonld
JSON-LD parser and serializer plugins for RDFLib (Python 2.6+)
Stars: ✭ 250 (-7.75%)
Mutual labels:  rdf, serializer, parser
rdflib-hdt
A Store back-end for rdflib to allow for reading and querying HDT documents
Stars: ✭ 18 (-93.36%)
Mutual labels:  sparql, rdf
semagrow
A SPARQL query federator of heterogeneous data sources
Stars: ✭ 27 (-90.04%)
Mutual labels:  sparql, rdf
IGUANA
IGUANA is a benchmark execution framework for querying HTTP endpoints and CLI Applications such as Triple Stores. Contact: [email protected]
Stars: ✭ 22 (-91.88%)
Mutual labels:  sparql, rdf
LinkedDataHub
The Knowledge Graph notebook. Apache license.
Stars: ✭ 150 (-44.65%)
Mutual labels:  sparql, rdf
mobi
Mobi is a decentralized, federated, and distributed graph data platform for teams and communities to publish and discover data, data models, and analytics that are instantly consumable.
Stars: ✭ 41 (-84.87%)
Mutual labels:  sparql, rdf
ont-api
ONT-API (OWL-API over Apache Jena)
Stars: ✭ 20 (-92.62%)
Mutual labels:  sparql, rdf
SEPA
Get notifications about changes in your SPARQL endpoint.
Stars: ✭ 21 (-92.25%)
Mutual labels:  sparql, rdf
graph-explorer
Graph Explorer can be used to explore RDF graphs in SPARQL endpoints or on the web.
Stars: ✭ 30 (-88.93%)
Mutual labels:  sparql, rdf
cognipy
In-memory Graph Database and Knowledge Graph with Natural Language Interface, compatible with Pandas
Stars: ✭ 31 (-88.56%)
Mutual labels:  sparql, rdf
jarql
SPARQL for JSON: Turn JSON into RDF using SPARQL syntax
Stars: ✭ 19 (-92.99%)
Mutual labels:  sparql, rdf
joinup-dev
The Joinup project moved to https://git.fpfis.eu/ec-europa/digit-joinup-reference
Stars: ✭ 41 (-84.87%)
Mutual labels:  sparql, rdf
rdf2x
RDF2X converts big RDF datasets to the relational database model, CSV, JSON and ElasticSearch.
Stars: ✭ 43 (-84.13%)
Mutual labels:  sparql, rdf
jsonld-streaming-serializer.js
A fast and lightweight streaming JSON-LD serializer for JavaScript
Stars: ✭ 20 (-92.62%)
Mutual labels:  rdf, serializer
CSV2RDF
Streaming, transforming, SPARQL-based CSV to RDF converter. Apache license.
Stars: ✭ 48 (-82.29%)
Mutual labels:  sparql, rdf
sparql-micro-service
SPARQL micro-services: A lightweight approach to query Web APIs with SPARQL
Stars: ✭ 22 (-91.88%)
Mutual labels:  sparql, rdf
AskNowNQS
A question answering system for RDF knowledge graphs.
Stars: ✭ 32 (-88.19%)
Mutual labels:  sparql, rdf

SPARQL.js – A SPARQL 1.1 parser for JavaScript

Build Status npm version DOI

The SPARQL 1.1 Query Language allows to query datasources of RDF triples. SPARQL.js translates SPARQL into JSON and back, so you can parse and build SPARQL queries in your JavaScript applications. It also contains support for the SPARQL* extension under the sparqlStar option.

It fully supports the SPARQL 1.1 specification, including property paths, federation, and updates.

Usage

Library

// Parse a SPARQL query to a JSON object
var SparqlParser = require('sparqljs').Parser;
var parser = new SparqlParser();
var parsedQuery = parser.parse(
  'PREFIX foaf: <http://xmlns.com/foaf/0.1/> ' +
  'SELECT * { ?mickey foaf:name "Mickey Mouse"@en; foaf:knows ?other. }');

// Regenerate a SPARQL query from a JSON object
var SparqlGenerator = require('sparqljs').Generator;
var generator = new SparqlGenerator({ /* prefixes, baseIRI, factory, sparqlStar */ });
parsedQuery.variables = ['?mickey'];
var generatedQuery = generator.stringify(parsedQuery);

Set sparqlStar to true to allow SPARQL* syntax.

Standalone

$ sparql-to-json --strict query.sparql

Parse SPARQL* syntax by default. For pure SPARQL 1.1, use the --strict flag.

Representation

Queries are represented in a JSON structure. The most easy way to get acquainted with this structure is to try the examples in the queries folder through sparql-to-json. All examples of the SPARQL 1.1 specification have been included, in case you wonder how a specific syntactical construct is represented.

Here is a simple query in SPARQL:

PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
SELECT ?p ?c WHERE {
    ?p a dbpedia-owl:Artist.
    ?p dbpedia-owl:birthPlace ?c.
    ?c <http://xmlns.com/foaf/0.1/name> "York"@en.
}

And here is the same query in JSON:

{
  "queryType": "SELECT",
  "variables": [
    {
      "termType": "Variable",
      "value": "p"
    },
    {
      "termType": "Variable",
      "value": "c"
    }
  ],
  "where": [
    {
      "type": "bgp",
      "triples": [
        {
          "subject": {
            "termType": "Variable",
            "value": "p"
          },
          "predicate": {
            "termType": "NamedNode",
            "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
          },
          "object": {
            "termType": "NamedNode",
            "value": "http://dbpedia.org/ontology/Artist"
          }
        },
        {
          "subject": {
            "termType": "Variable",
            "value": "p"
          },
          "predicate": {
            "termType": "NamedNode",
            "value": "http://dbpedia.org/ontology/birthPlace"
          },
          "object": {
            "termType": "Variable",
            "value": "c"
          }
        },
        {
          "subject": {
            "termType": "Variable",
            "value": "c"
          },
          "predicate": {
            "termType": "NamedNode",
            "value": "http://xmlns.com/foaf/0.1/name"
          },
          "object": {
            "termType": "Literal",
            "value": "York",
            "language": "en",
            "datatype": {
              "termType": "NamedNode",
              "value": "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
            }
          }
        }
      ]
    }
  ],
  "type": "query",
  "prefixes": {
    "dbpedia-owl": "http://dbpedia.org/ontology/"
  }
}

The representation of triples uses the RDF/JS representation.

Installation

$ [sudo] npm [-g] install sparqljs

License, status and contributions

The SPARQL.js library is copyrighted by Ruben Verborgh and released under the MIT License.

Contributions are welcome, and bug reports or pull requests are always helpful.

Contributors

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].