Neo4j Client
(CLI and library)

View the Project on GitHub cleishm/libneo4j-client

Fork me on GitHub


neo4j-client is a command shell (CLI) for Neo4j. It supports secure connections to Neo4j server, sending of statements (including multiline statements), persistent command history, and rendering of results to tables or CSV.

neo4j-client utilizes the Bolt Network Protocol, and will work with any server that supports Bolt.

For more details, see the FAQ.


neo4j-client is known to work on GNU/Linux, Mac OS X and FreeBSD. It requires neo4j 3.0.0 or later.

Getting Started

If you're using Mac OS X, neo4j-client can be installed using homebrew:

$ brew install cleishm/neo4j/neo4j-client

If you're using Ubuntu, neo4j-client can be installed using APT:

$ sudo add-apt-repository ppa:cleishm/neo4j
$ sudo apt-get update
$ sudo apt-get install neo4j-client libneo4j-client-dev

For other platforms, please see Building below.

neo4j-client Usage

Example interactive usage:

$ neo4j-client -u neo4j localhost
The authenticity of host 'localhost:7687' could not be established.
TLS certificate fingerprint is ded0fd2e893cd0b579f47f7798e10cb68dfa2fd3bc9b3c973157da81bab451d74f9452ba99a9c5f66dadb8a360959e5ebd8abb2d7c81230841e60531a96d268.
Would you like to trust this host (NO/yes/once)? yes
Password: *****
neo4j> :help
:quit                  Exit the shell
:connect '<url>'       Connect to the specified URL
:connect host [port]   Connect to the specified host (and optional port)
:disconnect            Disconnect the client from the server
:export name=val ...   Export parameters for queries
:uexport name ...      Unexport parameters for queries
:reset                 Reset the session with the server
:set option=value ...  Set shell options
:status                Show the client connection status
:help                  Show usage information
:output (table|csv)    Set the output format
:width (<n>|auto)      Set the number of columns in the table output
neo4j> :status
Connected to 'neo4j://neo4j@localhost:7687'
neo4j> MATCH (n:Person) RETURN n LIMIT 3;
| n                                                                          |
| (:Person{born:1964,name:"Keanu Reeves"})                                   |
| (:Person{born:1967,name:"Carrie-Anne Moss"})                               |
| (:Person{born:1961,name:"Laurence Fishburne"})                             |
neo4j> :set
neo4j> :set output=csv
neo4j> MATCH (n:Person) RETURN AS name, n.born AS born LIMIT 3;
"Keanu Reeves",1964
"Carrie-Anne Moss",1967
"Laurence Fishburne",1961
neo4j> :quit

Example non-interactive usage:

$ echo "MATCH (n:Person) RETURN AS name, n.born AS born LIMIT 3" | \
     neo4j-client -u neo4j -P localhost > result.csv
Password: *****
$ cat result.csv
"Keanu Reeves",1964
"Carrie-Anne Moss",1967
"Laurence Fishburne",1961

Evaluating source files:

$ cat query.cyp
:set echo
:export name='Emil'

// Create a person node if it doesn't exist
MERGE (:Person {name: {name}});

// return the total number of people
MATCH (n:Person)
RETURN count(n);
$ neo4j-client -u neo4j -p pass -o result.out -i query.cyp
$ cat result.out
+:export name='Emil'
+MERGE (:Person {name: {name}});
Nodes created: 1
Properties set: 1
Labels added: 1
+MATCH (n:Person)
 RETURN count(n);


libneo4j-client is a client library for Neo4j, written in C, and intended as a foundation on which basic tools and drivers for various languages may be built. libneo4j-client takes care of all the detail of establishing a session with a Neo4j server, sending statements for evaluation, and retrieving results.

libneo4j-client provides a single C header file, neo4j-client.h, for inclusion in source code using the libneo4j-client API. The API is described in the API Documentation.

libneo4j-client can be included in your project by linking the library at compile time, typically using the linking flags -lneo4j-client -lssl -lcrypto. Alternatively, libneo4j-client ships with a pkg-config description file, enabling you to obtain the required flags using pkg-config --libs libneo4j-client.

API Documentation

API documentation for the latest release is available at


#include <neo4j-client.h>
#include <errno.h>
#include <stdio.h>

int main(int argc, char *argv[])

    /* use NEO4J_INSECURE when connecting to disable TLS */
    neo4j_connection_t *connection =
            neo4j_connect("neo4j://user:pass@localhost:7687", NULL, NEO4J_INSECURE);
    if (connection == NULL)
        neo4j_perror(stderr, errno, "Connection failed");
        return EXIT_FAILURE;

    neo4j_session_t *session = neo4j_new_session(connection);
    if (session == NULL)
        neo4j_perror(stderr, errno, "Failed to start session");
        return EXIT_FAILURE;

    neo4j_result_stream_t *results =
            neo4j_run(session, "RETURN 'hello world'", neo4j_null);
    if (results == NULL)
        neo4j_perror(stderr, errno, "Failed to run statement");
        return EXIT_FAILURE;

    neo4j_result_t *result = neo4j_fetch_next(results);
    if (results == NULL)
        neo4j_perror(stderr, errno, "Failed to fetch result");
        return EXIT_FAILURE;

    neo4j_value_t value = neo4j_result_field(result, 0);
    char buf[128];
    printf("%s\n", neo4j_tostring(value, buf, sizeof(buf)));

    return EXIT_SUCCESS;


To build software using libneo4j-client, consider installing libneo4j-client using the package management system for your operating system (currently only Mac OS X). See Getting Started for detail.

NOTE: Recent versions of Mac OS X ship without the OpenSSL header files, and autoconf doesn't pick this up (yet). Please use the homebrew package to install on Mac OS X.

If libneo4j-client is not available via your package management system, please download the latest release and then:

$ ./configure
$ make clean check
$ sudo make install

libneo4j-client requires OpenSSL, although this can be disabled by invoking configure with --without-tls.

neo4j-client also requires some dependencies to build, including libedit and libcypher-parser. If these are not available, the library can be built without neo4j-client, by invoking configure with --disable-tools.


Having trouble with libneo4j-client or neo4j-client? Please raise any issues with usage on StackOverflow. If you've found a bug in the code for libneo4j-client, please raise an issue on GitHub and include details of how to reproduce the bug.


Contributions to libneo4j-client are welcome and encouraged! Please see the GitHub repository for more detail.


libneo4j-client is licensed under the Apache License, Version 2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.