Tag Archives: json

for your convenience: command line cypher the comfortable way with httpie

Today a tweet from @rafacm drove my attention to httpie, a cURL tool for humans. Using cURL is cumbersome and noisy, httpie makes it fairly easily usable.

install httpie

Httpie is python based therefore it’s trivial to install using easy_install/pip. On my Ubuntu 13.10 box I’ve used:

It fetches the package and installs it locally.

running cypher statements

Running cypher statements is much more easy than using cURL. In cURL you have to manually assemble a json snippet to pass in, deal with content types. httpie makes it easy. The following code snippets are intended to be run on a single line, for readability I’ve splitted them.

To use the old-style non-transactional cypher endpoint just use

for non-parameterized queries and

for parameterized queries. Httpie sets the ‘Accept’ header to json if option -j is used. In case  of -j httpie assembles the key-value request items internally into json format as well. Since the params contains a json map it needs to be assigned with “:=” instead of just “=”.

For the transactional Cypher endpoint in Neo4j 2.0 httpie can be used like this: