Difference between revisions of " Client Libraries"

From Blazegraph
Jump to: navigation, search
(Query)
 
(5 intermediate revisions by one other user not shown)
Line 6: Line 6:
 
! Pyton client (Pymantic)
 
! Pyton client (Pymantic)
 
! dotNetRDF
 
! dotNetRDF
 +
! JAVA Client
 
|-
 
|-
|  colspan="5"    style="background: #54B746;" |  
+
|  colspan="6"    style="background: #54B746;" |  
 
|-
 
|-
| rowspan="13" | QUERY
+
| rowspan="13" | [https://wiki.blazegraph.com/wiki/index.php/REST_API#QUERY QUERY]
 
| colspan="2"    | <pre>GET Request-URI ?query=...</pre>
 
| colspan="2"    | <pre>GET Request-URI ?query=...</pre>
 +
|align="center"  | +
 
|align="center"  | +
 
|align="center"  | +
 
|align="center"  | +
 
|align="center"  | +
 
|-
 
|-
 
| colspan="2"    |<pre> POST Request-URI ?query=...</pre>
 
| colspan="2"    |<pre> POST Request-URI ?query=...</pre>
 +
|align="center"  | +
 
|align="center"  | +
 
|align="center"  | +
 
|align="center"  | +
 
|align="center"  | +
Line 21: Line 24:
 
| timestamp
 
| timestamp
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|align="center"  | +
 
|align="center"  | +
 
|-
 
|-
 
| explain
 
| explain
 +
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|-
 
|-
 
| analytic
 
| analytic
 +
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
Line 34: Line 40:
 
|align="center"  | +
 
|align="center"  | +
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|-
 
|-
 
| named-graph-uri
 
| named-graph-uri
 
|align="center"  | +
 
|align="center"  | +
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|-
 
|-
 
| format
 
| format
 +
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
Line 46: Line 55:
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|-
 
|-
 
| includeInferred
 
| includeInferred
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|-
 
|-
| timeout
+
| maxQueryTimeMillis
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|-
 
|-
 
| ${var}=Value
 
| ${var}=Value
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|-
 
|-
 
| headers
 
| headers
 
| X-BIGDATA-MAX-QUERY-MILLIS
 
| X-BIGDATA-MAX-QUERY-MILLIS
 +
|align="center"  | +
 
|align="center"  | +
 
|align="center"  | +
 
|align="center"  | +
 
|align="center"  | +
 
|-
 
|-
|  colspan="5"  style="background: #54B746;"  | INSERT
+
|  colspan="6"  style="background: #54B746;"  | INSERT
 
|-
 
|-
| INSERT RDF (POST with Body)
+
| [https://wiki.blazegraph.com/wiki/index.php/REST_API#INSERT_RDF_.28POST_with_Body.29 INSERT RDF (POST with Body)]
 
| colspan="2"  | <pre>POST Request-URI
 
| colspan="2"  | <pre>POST Request-URI
 
...  
 
...  
Line 74: Line 88:
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|-
 
|-
| INSERT RDF (POST with URLs)
+
| [https://wiki.blazegraph.com/wiki/index.php/REST_API#INSERT_RDF_.28POST_with_URLs.29 INSERT RDF (POST with URLs)]
 
|colspan="2"    | <pre>POST Request-URI ?uri=URI</pre>
 
|colspan="2"    | <pre>POST Request-URI ?uri=URI</pre>
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|-
 
|-
| colspan="5"  style="background: #54B746;"  | DELETE
+
| colspan="6"  style="background: #54B746;"  | DELETE
 
|-
 
|-
| DELETE with Query
+
| [https://wiki.blazegraph.com/wiki/index.php/REST_API#DELETE_with_Query DELETE with Query]
 
|colspan="2"    | <pre>DELETE Request-URI ?query=...</pre>
 
|colspan="2"    | <pre>DELETE Request-URI ?query=...</pre>
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|-
 
|-
| DELETE with Body (using POST)
+
| [https://wiki.blazegraph.com/wiki/index.php/REST_API#DELETE_with_Body_.28using_POST.29 DELETE with Body (using POST)]
 
|colspan="2"    | <pre>POST Request-URI ?delete
 
|colspan="2"    | <pre>POST Request-URI ?delete
 
...
 
...
Line 95: Line 112:
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|-
 
|-
|  colspan="5"  style="background: #54B746;"  | UPDATE
+
|  colspan="6"  style="background: #54B746;"  | UPDATE
 
|-
 
|-
| rowspan="3" | UPDATE (SPARQL 1.1 UPDATE)
+
| rowspan="3" | [https://wiki.blazegraph.com/wiki/index.php/REST_API#UPDATE_.28SPARQL_1.1_UPDATE.29 UPDATE (SPARQL 1.1 UPDATE)]
 
| colspan="2"  | <pre> POST Request-URI ?update=... </pre>
 
| colspan="2"  | <pre> POST Request-URI ?update=... </pre>
 
|align="center"  | +
 
|align="center"  | +
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|-
 
|-
 
| rowspan="2" | parameters
 
| rowspan="2" | parameters
Line 107: Line 126:
 
|align="center"  | +
 
|align="center"  | +
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|-
 
|-
 
| using-named-graph-uri  
 
| using-named-graph-uri  
 
|align="center"  | +
 
|align="center"  | +
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|-
 
|-
| UPDATE (DELETE + INSERT)
+
| [https://wiki.blazegraph.com/wiki/index.php/REST_API#UPDATE_.28DELETE_statements_selected_by_a_QUERY_plus_INSERT_statements_from_Request_Body_using_PUT.29 UPDATE (DELETE + INSERT)]
 
| colspan="2" | <pre>PUT Request-URI ?query=...
 
| colspan="2" | <pre>PUT Request-URI ?query=...
 
...
 
...
Line 119: Line 140:
 
BODY </pre>
 
BODY </pre>
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|align="center"  | +
 
|align="center"  | +
 
|-
 
|-
| UPDATE  
+
| [https://wiki.blazegraph.com/wiki/index.php/REST_API#UPDATE_.28POST_with_Multi-Part_Request_Body.29 UPDATE (POST with Multi-Part Request Body)]
(POST with Multi-Part  
+
Request Body)
+
 
| colspan="2" | <pre>POST Request-URI ?updatePost
 
| colspan="2" | <pre>POST Request-URI ?updatePost
 
...
 
...
Line 138: Line 158:
 
BODY </pre>
 
BODY </pre>
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|align="center"  | +
 
|align="center"  | +
 
|-
 
|-
|  colspan="5"    style="background: #54B746;" | Multi-Tenancy API
+
|  colspan="6"    style="background: #54B746;" | Multi-Tenancy API
 
|-
 
|-
| DESCRIBE DATA SETS
+
| [https://wiki.blazegraph.com/wiki/index.php/REST_API#DESCRIBE_DATA_SETS DESCRIBE DATA SETS]
 
| colspan="2" | <pre>GET /bigdata/namespace</pre>
 
| colspan="2" | <pre>GET /bigdata/namespace</pre>
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|-
 
|-
| CREATE DATA SET
+
| [https://wiki.blazegraph.com/wiki/index.php/REST_API#CREATE_DATA_SET CREATE DATA SET]
 
| colspan="2" | <pre>POST /bigdata/namespace
 
| colspan="2" | <pre>POST /bigdata/namespace
 
...
 
...
Line 155: Line 177:
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|-
 
|-
| DESTROY DATA SET
+
| [https://wiki.blazegraph.com/wiki/index.php/REST_API#DESTROY_DATA_SET DESTROY DATA SET]
 
| colspan="2" | <pre>DELETE /bigdata/namespace/NAMESPACE</pre>
 
| colspan="2" | <pre>DELETE /bigdata/namespace/NAMESPACE</pre>
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|-
 
|-
| colspan="5"  style="background: #54B746;"  | Transaction Management API
+
| colspan="6"  style="background: #54B746;"  | Transaction Management API
 
|-
 
|-
|  
+
| [https://wiki.blazegraph.com/wiki/index.php/REST_API#Transaction_Management_API TX]
 
| colspan="2" | <pre>POST /bigdata/tx => txId</pre>
 
| colspan="2" | <pre>POST /bigdata/tx => txId</pre>
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|align="center"  | +
 
|align="center"  | +
 
|-
 
|-
| COMMIT-TX
+
| [https://wiki.blazegraph.com/wiki/index.php/REST_API#COMMIT-TX COMMIT-TX]
 
| colspan="2" |<pre>POST /bigdata/tx/txid?COMMIT</pre>
 
| colspan="2" |<pre>POST /bigdata/tx/txid?COMMIT</pre>
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|align="center"  | +
 
|align="center"  | +
 
|-
 
|-
| LIST-TX
+
| [https://wiki.blazegraph.com/wiki/index.php/REST_API#LIST-TX LIST-TX]
 
| colspan="2" |<pre>GET /bigdata/tx</pre>
 
| colspan="2" |<pre>GET /bigdata/tx</pre>
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|-
 
|-
| CREATE-TX
+
| [https://wiki.blazegraph.com/wiki/index.php/REST_API#CREATE-TX CREATE-TX]
 
| colspan="2" |<pre>POST /bigdata/tx(?timestamp=TIMESTAMP)</pre>
 
| colspan="2" |<pre>POST /bigdata/tx(?timestamp=TIMESTAMP)</pre>
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|align="center"  | +
 
|align="center"  | +
 
|-
 
|-
| STATUS-TX
+
| [https://wiki.blazegraph.com/wiki/index.php/REST_API#STATUS-TX STATUS-TX]
 
| colspan="2" |<pre>POST /bigdata/tx/txId?STATUS</pre>
 
| colspan="2" |<pre>POST /bigdata/tx/txId?STATUS</pre>
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|-
 
|-
| ABORT-TX
+
| [https://wiki.blazegraph.com/wiki/index.php/REST_API#ABORT-TX ABORT-TX]
 
| colspan="2" |<pre>POST /bigdata/tx/txId?ABORT</pre>
 
| colspan="2" |<pre>POST /bigdata/tx/txId?ABORT</pre>
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|align="center"  | +
 
|align="center"  | +
 
|-
 
|-
| PREPARE-TX
+
| [https://wiki.blazegraph.com/wiki/index.php/REST_API#PREPARE-TX PREPARE-TX]
 
| colspan="2" |<pre>POST /bigdata/tx/txId?PREPARE</pre>
 
| colspan="2" |<pre>POST /bigdata/tx/txId?PREPARE</pre>
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|-
 
|-
| colspan="5"  style="background: #54B746;" | Access Path Operations
+
| colspan="6"  style="background: #54B746;" | Access Path Operations
 
|-
 
|-
| FAST RANGE COUNTS
+
| [https://wiki.blazegraph.com/wiki/index.php/REST_API#FAST_RANGE_COUNTS FAST RANGE COUNTS]
 
|  colspan="2" |<pre>GET Request-URI ?ESTCARD&([s|p|o|c]=(uri|literal))[&exact=(true|false)+</pre>
 
|  colspan="2" |<pre>GET Request-URI ?ESTCARD&([s|p|o|c]=(uri|literal))[&exact=(true|false)+</pre>
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|-
 
|-
| HASSTMT
+
| [https://wiki.blazegraph.com/wiki/index.php/REST_API#HASSTMT HASSTMT]
 
|  colspan="2" |<pre>GET Request-URI ?HASSTMT&([s|p|o|c]=(uri|literal))[&includeInferred=(true|false)+</pre>
 
|  colspan="2" |<pre>GET Request-URI ?HASSTMT&([s|p|o|c]=(uri|literal))[&includeInferred=(true|false)+</pre>
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|-
 
|-
| rowspan="2" | GETSTMTS
+
| rowspan="2" | [https://wiki.blazegraph.com/wiki/index.php/REST_API#GETSTMTS GETSTMTS]
 
|  colspan="2" |<pre>GET Request-URI ?GETSTMTS
 
|  colspan="2" |<pre>GET Request-URI ?GETSTMTS
 
...
 
...
Line 217: Line 250:
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|-
 
|-
 
|  colspan="2" |<pre>POST Request-URI ?GETSTMTS
 
|  colspan="2" |<pre>POST Request-URI ?GETSTMTS
Line 224: Line 258:
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|-
 
|-
| DELETE with Access Path
+
| [https://wiki.blazegraph.com/wiki/index.php/REST_API#DELETE_with_Access_Path DELETE with Access Path]
 
|  colspan="2" |<pre>DELETE Request-URI ?([s|p|o|c]=(uri|literal))+</pre>
 
|  colspan="2" |<pre>DELETE Request-URI ?([s|p|o|c]=(uri|literal))+</pre>
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | only c parameter
 
|align="center"  | only c parameter
 +
|align="center"  | +
 
|-
 
|-
| colspan="5"  style="background: #54B746;"  |   
+
| colspan="6"  style="background: #54B746;"  |   
 
|-
 
|-
| STATUS
+
| [https://wiki.blazegraph.com/wiki/index.php/REST_API#STATUS STATUS]
 
|  colspan="2" |<pre>GET /status</pre>
 
|  colspan="2" |<pre>GET /status</pre>
 +
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|-
 
|-
| CANCEL
+
| [https://wiki.blazegraph.com/wiki/index.php/REST_API#CANCEL CANCEL]
 
|  colspan="2" |<pre>POST /bigdata/sparql/?cancelQuery&queryId=....</pre>
 
|  colspan="2" |<pre>POST /bigdata/sparql/?cancelQuery&queryId=....</pre>
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 
|align="center"  | -
 +
|align="center"  | +
 
|}
 
|}
  
Line 303: Line 341:
 
     Console.WriteLine(result.ToString());
 
     Console.WriteLine(result.ToString());
 
}
 
}
</pre>
+
</pre>hp support number>
  
 
==Python Client Support==
 
==Python Client Support==
Line 319: Line 357:
  
 
===Quick Start===
 
===Quick Start===
 +
Load some RDF data from file '/tmp/data.n3'.
 +
 
<pre>
 
<pre>
 
from pymantic import sparql
 
from pymantic import sparql
  
server = sparql.SPARQLServer('http://127.0.0.1:9999/bigdata/sparql')
+
server = sparql.SPARQLServer('http://127.0.0.1:9999/blazegraph/sparql')
  
 
# Loading data to Blazegraph
 
# Loading data to Blazegraph

Latest revision as of 18:49, 28 August 2017

Features support matrix

REST Endpoint Call / parameters Pyton client (Pymantic) dotNetRDF JAVA Client
QUERY
GET Request-URI ?query=...
+ + +
 POST Request-URI ?query=...
+ + +
parameters timestamp - + +
explain - - -
analytic - - -
default-graph-uri + - +
named-graph-uri + - +
format - - -
baseURI - - +
includeInferred - - +
maxQueryTimeMillis - - +
${var}=Value - - +
headers X-BIGDATA-MAX-QUERY-MILLIS + + +
INSERT
INSERT RDF (POST with Body)
POST Request-URI
... 
Content-Type:
...
BODY
- - +
INSERT RDF (POST with URLs)
POST Request-URI ?uri=URI
- - +
DELETE
DELETE with Query
DELETE Request-URI ?query=...
- - +
DELETE with Body (using POST)
POST Request-URI ?delete
...
Content-Type
...
BODY
- - +
UPDATE
UPDATE (SPARQL 1.1 UPDATE)
 POST Request-URI ?update=... 
+ - +
parameters using-graph-uri + - +
using-named-graph-uri + - +
UPDATE (DELETE + INSERT)
PUT Request-URI ?query=...
...
Content-Type
...
BODY 
- + +
UPDATE (POST with Multi-Part Request Body)
POST Request-URI ?updatePost
...
Content-Type: multipart/form-data; boundary=...
...
form-data; name="remove"
Content-Type: ...
Content-Body
...
form-data; name="add"
Content-Type: ...
Content-Body
...
BODY 
- + +
Multi-Tenancy API
DESCRIBE DATA SETS
GET /bigdata/namespace
- - +
CREATE DATA SET
POST /bigdata/namespace
...
Content-Type
...
BODY
- - +
DESTROY DATA SET
DELETE /bigdata/namespace/NAMESPACE
- - +
Transaction Management API
TX
POST /bigdata/tx => txId
- + +
COMMIT-TX
POST /bigdata/tx/txid?COMMIT
- + +
LIST-TX
GET /bigdata/tx
- - +
CREATE-TX
POST /bigdata/tx(?timestamp=TIMESTAMP)
- + +
STATUS-TX
POST /bigdata/tx/txId?STATUS
- - +
ABORT-TX
POST /bigdata/tx/txId?ABORT
- + +
PREPARE-TX
POST /bigdata/tx/txId?PREPARE
- - +
Access Path Operations
FAST RANGE COUNTS
GET Request-URI ?ESTCARD&([s|p|o|c]=(uri|literal))[&exact=(true|false)+
- - +
HASSTMT
GET Request-URI ?HASSTMT&([s|p|o|c]=(uri|literal))[&includeInferred=(true|false)+
- - +
GETSTMTS
GET Request-URI ?GETSTMTS
...
Content-Type
...
- - +
POST Request-URI ?GETSTMTS
...
Content-Type
…
- - +
DELETE with Access Path
DELETE Request-URI ?([s|p|o|c]=(uri|literal))+
- only c parameter +
STATUS
GET /status
- - -
CANCEL
POST /bigdata/sparql/?cancelQuery&queryId=....
- - +

dotNetRDF Client Support

Usage

Blazegraph dotNetRDF client code is here.

Download BlazegraphConnector.dll and dotNetRDF dll files. Then add them to your project or include by the NuGet.
Look at the dotNetRDF documentation.


Examples of using Blazegraph connector

Create new graph

BlazegraphConnector connector = new BlazegraphConnector("http://localhost:9999/bigdata/");

Graph newGraph = new Graph();
newGraph.BaseUri = UriFactory.Create("http://example/bookStore");

Triple triple = new Triple(
    newGraph.CreateUriNode(UriFactory.Create("http://example/book1")),
    newGraph.CreateUriNode(UriFactory.Create("http://example.org/ns#price")),
    newGraph.CreateLiteralNode("42", new Uri(XmlSpecsHelper.XmlSchemaDataTypeInteger))
);
newGraph.Assert(triple);

connector.SaveGraph(newGraph);

Load graph

Graph loadGraph = new Graph();
connector.LoadGraph(loadGraph, UriFactory.Create("http://example/bookStore"));

Update graph

Triple triple2remove = new Triple(
    newGraph.CreateUriNode(UriFactory.Create("http://example/book1")),
    newGraph.CreateUriNode(UriFactory.Create("http://example.org/ns#price")),
    newGraph.CreateLiteralNode("42", new Uri(XmlSpecsHelper.XmlSchemaDataTypeInteger))
);
Triple triple2add = new Triple(
    newGraph.CreateUriNode(UriFactory.Create("http://example/book1")),
    newGraph.CreateUriNode(UriFactory.Create("http://purl.org/dc/elements/1.1/title")),
    newGraph.CreateLiteralNode("Fundamentals of Compiler Design", new Uri(XmlSpecsHelper.XmlSchemaDataTypeString))
);
connector.UpdateGraph(
    UriFactory.Create("http://example/bookStore"),
    new List<Triple>() { triple2add },
    new List<Triple>() { triple2remove }
);

Delete graph

connector.DeleteGraph(UriFactory.Create("http://example/bookStore"));

Query

SparqlResultSet resultSet = (SparqlResultSet)connector.Query("SELECT * { ?s ?p ?o }");
foreach (SparqlResult result in resultSet.Results) {
    Console.WriteLine(result.ToString());
}
hp support number>

Python Client Support

Pymantic (Semantic Web and RDF library for Python ) could be used as a client for Blazegraph.
You can download the code here.

Requirements

Pymantic requires Python 2.6 or higher. Lepl is used for the Turtle and NTriples parser. httplib2 is used for HTTP requests and the SPARQL client. simplejson and lxml are required by the SPARQL client as well.

Install

$ python setup.py install

This will install Pymantic and all its dependencies.

Quick Start

Load some RDF data from file '/tmp/data.n3'.

from pymantic import sparql

server = sparql.SPARQLServer('http://127.0.0.1:9999/blazegraph/sparql')

# Loading data to Blazegraph
server.update('load <file:///tmp/data.n3>')

# Executing query
result = server.query('select * where { <http://blazegraph.com/blazegraph> ?p ?o }')
for b in result['results']['bindings']:
    print "%s %s" (b['p']['value'], b['o']['value']