The Amazon Neptune openCypher HTTPS endpoint - Amazon Neptune

The Amazon Neptune openCypher HTTPS endpoint

openCypher read and write queries on the HTTPS endpoint

The openCypher HTTPS endpoint supports read and update queries using both the GET and the POST method. The DELETE and PUT methods are not supported.

The following instructions walk you through connecting to the openCypher 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 syntax is:

HTTPS://(the server):(the port number)/openCypher

Here are sample read queries, one that uses POST and one that uses GET:

1. Using POST:

curl HTTPS://server:port/openCypher \ -d "query=MATCH (n1) RETURN n1;"

2. Using GET (the query string is URL-encoded):

curl -X GET \ "HTTPS://server:port/openCypher?query=MATCH%20(n1)%20RETURN%20n1"

Here are sample write/update queries, one that uses POST and one that uses GET:

1. Using POST:

curl HTTPS://server:port/openCypher \ -d "query=CREATE (n:Person { age: 25 })"

2. Using GET (the query string is URL-encoded):

curl -X GET \ "HTTPS://server:port/openCypher?query=CREATE%20(n%3APerson%20%7B%20age%3A%2025%20%7D)"

The default openCypher JSON results format

The following JSON format is returned by default, or by setting the request header explicitly to Accept: application/json. This format is designed to be easily parsed into objects using native-language features of most libraries.

The JSON document that is returned contains one field, results, which contains the query return values. The examples below show the JSON formatting for common values.

Value response example:

{ "results": [ { "count(a)": 121 } ] }

Node response example:

{ "results": [ { "a": { "~id": "22", "~entityType": "node", "~labels": [ "airport" ], "~properties": { "desc": "Seattle-Tacoma", "lon": -122.30899810791, "runways": 3, "type": "airport", "country": "US", "region": "US-WA", "lat": 47.4490013122559, "elev": 432, "city": "Seattle", "icao": "KSEA", "code": "SEA", "longest": 11901 } } } ] }

Relationship response example:

{ "results": [ { "r": { "~id": "7389", "~entityType": "relationship", "~start": "22", "~end": "151", "~type": "route", "~properties": { "dist": 956 } } } ] }

Path response example:

{ "results": [ { "p": [ { "~id": "22", "~entityType": "node", "~labels": [ "airport" ], "~properties": { "desc": "Seattle-Tacoma", "lon": -122.30899810791, "runways": 3, "type": "airport", "country": "US", "region": "US-WA", "lat": 47.4490013122559, "elev": 432, "city": "Seattle", "icao": "KSEA", "code": "SEA", "longest": 11901 } }, { "~id": "7389", "~entityType": "relationship", "~start": "22", "~end": "151", "~type": "route", "~properties": { "dist": 956 } }, { "~id": "151", "~entityType": "node", "~labels": [ "airport" ], "~properties": { "desc": "Ontario International Airport", "lon": -117.600997924805, "runways": 2, "type": "airport", "country": "US", "region": "US-CA", "lat": 34.0559997558594, "elev": 944, "city": "Ontario", "icao": "KONT", "code": "ONT", "longest": 12198 } } ] } ] }