Using the HTTP REST Endpoint to Connect to a Neptune DB Instance
Amazon Neptune provides an HTTP endpoint for SPARQL queries. The REST interface is compatible with SPARQL version 1.1.
The following instructions walk you through connecting to the SPARQL endpoint using
the
curl
command and HTTP. You must follow these instructions from an Amazon EC2 instance
in the same virtual private cloud (VPC) as your Neptune DB instance.
The HTTP endpoint for SPARQL queries to a Neptune DB instance is
http://
.
your-neptune-endpoint
:8182/sparql
Note
For information about finding the hostname of your Neptune DB instance, see the Connecting to Amazon Neptune Endpoints section.
QUERY using HTTP POST
The following example uses curl to submit a SPARQL QUERY
through HTTP POST.
curl -X POST --data-binary 'query=select ?s ?p ?o where {?s ?p ?o} limit 10' http://
your-neptune-endpoint
:8182/sparql
The preceding example returns up to 10 of the triples (subject-predicate-object) in
the
graph by using the ?s ?p ?o
query with a limit of 10. To query for something
else, replace it with another SPARQL query.
Note
The default MIME type of a response is application/sparql-results+json
for
SELECT
and ASK
queries.
The default MIME type of a response is application/n-quads
for
CONSTRUCT
and DESCRIBE
queries.
For a list of all available MIME types, see SPARQL HTTP Content Types.
UPDATE using HTTP POST
The following example uses curl to submit a SPARQL UPDATE
through HTTP POST.
curl -X POST --data-binary 'update=INSERT DATA { <http://test.com/s> <http://test.com/p> <http://test.com/o> . }' http://
your-neptune-endpoint
:8182/sparql
The preceding example inserts the following triple into the SPARQL default graph:
<http://test.com/s> <http://test.com/p> <http://test.com/o>
For more information about the Neptune SPARQL REST interface, see SPARQL HTTP API. For more information about Amazon Neptune, see Next Steps Using SPARQL.