4

How can I send (programatically) a cypher query to neo4j browser (via get/post) in order to display the resulted graph? e.g., something like: http://localhost:7474/browser/query='match n return n'

1 Answer 1

1

Yes, you can.

Example request

POST http://localhost:7474/db/data/cypher
Accept: application/json; charset=UTF-8
Content-Type: application/json
{
  "query" : "MATCH (x {name: 'I'})-[r]->(n) RETURN type(r), n.name, n.age",
  "params" : {
  }
}

Example response

200: OK
Content-Type: application/json; charset=UTF-8
{
  "columns" : [ "type(r)", "n.name", "n.age" ],
  "data" : [ [ "know", "him", 25 ], [ "know", "you", null ] ]
}
Sign up to request clarification or add additional context in comments.

6 Comments

You can have the response JSON tough, not a graph representation as he's asking.
JSON represents the graph query result just fine.
For OP -- I looked into the browser, but it's hard to figure out how this works. The browser uses a javascript object called "editor". Submitting queries I'm pretty sure boils down to POSTing exactly as I've specified here, plus some javascript magic to format the JSON as a pretty graph. All the JS in the server is minified though, (and looking on github, looks like it's originally coffeescript anyway) so whoever wrote that probably needs to cite exactly what POST the JS is doing to do the pretty graph of the result.
The browser actually uses the transactional endpoint with the "graph" resultDataContent attribute
I do not believe this response addresses the heart of the question, which I admit was a bit poorly phrased. I think the questioner wanted to have a cypher query displayed in the browser interface without having to type or copy/paste the query into the interface, not run a query and get a JSON result.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.