Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sage-client

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sage-client

Javascript client for SaGe interfaces

  • 2.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

sage-client

npm version Build Status

Javascript/typescript client for querying a SaGe server, built on top of the sparql-engine framework.

Installation

Requirements:

  • Node.js v8.11.2 or higher
  • npm v5.6.0 or higher

npm installation

npm install -g sage-client

Manual installation

git clone https://github.com/Callidon/sage-client.git
cd sage-client
npm install --production

CLI Usage

Usage: sage-client <server-url> <default-graph-iri> [options]

Execute a SPARQL query using a SaGe server and the IRI of the default RDF graph

Options:
  -q, --query <query>     evaluates the given SPARQL query
  -f, --file <file>       evaluates the SPARQL query stored in the given file
  -h, --help              output usage information

Library usage

The SaGe client can also be used as a regular Javascript/Typescript library

const { SageClient, Spy } = require('sage-client')

// Create a spy to collect stats during query execution
const spy = new Spy()

// The URL of the SaGe server
const serverURL = 'http://sage.univ-nantes.fr/sparql'
// The IRI of the default graph
const defaultGraph = 'http://sage.univ-nantes.fr/sparql/dbpedia-2016-04'
// The SPARQL query to execute
const query = `
prefix dbo: <http://dbpedia.org/ontology/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?movie ?title ?name WHERE {
  ?movie dbo:starring [ rdfs:label 'Brad Pitt'@en ];
  rdfs:label ?title;
  dbo:director [ rdfs:label ?name ].
  FILTER LANGMATCHES(LANG(?title), 'EN')
  FILTER LANGMATCHES(LANG(?name),  'EN')
}`

// Create a new SaGe client
const client = new SageClient(serverURL, defaultGraph, spy)

// Execute the SPARQL query
client.execute(query).subscribe(b => {
  // Print solutions bindings (in simple JSON format)
  console.log(b.toObject())
}, (error) => {
  // Report errors
  console.error('ERROR: An error occurred during query execution.')
  console.error(error.stack)
}, () => {
  // Print some starts after the end of query execution
  console.log('Query execution completed!')
  console.log(`SPARQL query evaluated with ${spy.nbHTTPCalls} HTTP request(s)`)
})

Keywords

FAQs

Package last updated on 22 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc