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
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 ] ]
}
6 Comments
MarcoL
You can have the response JSON tough, not a graph representation as he's asking.
buley
JSON represents the graph query result just fine.
FrobberOfBits
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.
Michael Hunger
The browser actually uses the transactional endpoint with the "graph" resultDataContent attribute
augustearth
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.
|