Amazon Neptune
User Guide (API Version 2017-11-29)

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

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.

Note

As discussed in Encryption in Transit: Connecting to Neptune Using SSL/HTTPS, the best practice is to connect to Neptune using HTTPS rather than HTTP. And in some Regions, you can only connect using HTTPS. The connection examples here all use HTTPS.

The following instructions walk you through connecting to the SPARQL endpoint using the curl command, connecting through HTTPS, and using HTTP syntax. 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:  https://your-neptune-endpoint:port/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' https://your-neptune-endpoint:port/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 media 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 the media types used by Neptune for serialization, see RDF Serialization Formats Used by Neptune SPARQL.

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 { <https://test.com/s> <https://test.com/p> <https://test.com/o> . }' https://your-neptune-endpoint:port/sparql

The preceding example inserts the following triple into the SPARQL default graph: <https://test.com/s> <https://test.com/p> <https://test.com/o>