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

Using the HTTP REST Endpoint to Connect to a Neptune DB Instance

Amazon Neptune provides an HTTP endpoint for Gremlin queries. The REST interface is compatible with Gremlin version 3.3.2.

The following instructions walk you through connecting to the Gremlin 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 Gremlin queries to a Neptune DB instance is http://your-neptune-endpoint:8182/gremlin.

Note

For information about finding the hostname of your Neptune DB instance, see Finding the Endpoint for a Neptune Cluster.

To connect to Neptune using the HTTP REST endpoint

  • The following example uses curl to submit a Gremlin query through HTTP POST. The query is submitted in JSON format in the body of the post as the gremlin property.

    curl -X POST -d '{"gremlin":"g.V().limit(1)"}' http://your-neptune-endpoint:8182/gremlin

    Note

    Amazon Neptune does not support the bindings property.

    You can also send queries through HTTP GET requests, but HTTP POST requests are recommended.

curl -G "http://your-neptune-endpoint:8182?gremlin=g.V().count()"

Important

The REST endpoint returns all results in a single JSON result set. If the result set is too large, this can cause an OutOfMemoryError exception on the Neptune DB instance.

For more information about the Gremlin REST interface, see Connecting via HTTP in the Apache TinkerPop3 documentation.

The preceding example returns the first vertex in the graph by using the g.V().limit(1) traversal. To query for something else, replace it with another Gremlin traversal.

For more information about Amazon Neptune, see Next Steps.