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 HTTPS REST Endpoint to Connect to a Neptune DB Instance

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

Note

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

The following instructions walk you through connecting to the Gremlin endpoint using the curl command and HTTPS. You must follow these instructions from an Amazon EC2 instance in the same virtual private cloud (VPC) as your Neptune DB instance.

The HTTPS endpoint for Gremlin queries to a Neptune DB instance is https://your-neptune-endpoint:port/gremlin.

Note

For information about finding the hostname of your Neptune DB instance, see Connecting to Amazon Neptune Endpoints.

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)"}' https://your-neptune-endpoint:port/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 "https://your-neptune-endpoint:port?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.