Should I use HTTP API or Driver API?

  1. Driver API:
    https://neo4j.com/docs/api/python-driver/4.1/

  2. HTTP API:
    https://neo4j.com/docs/http-api/current/

Is there a particular recommendation for when to use which API? For example, one may be more efficient than the other? Per the documentation, the driver api is called 'official API'. Does that mean the Driver API should be preferred?

Hi,

The recommended way would be to use the Driver API, a.k.a. the Bolt drivers.

Official drivers are supported in Java (or JVM in general), Python, Javascript/Node.js, .NET and Golang.
There are also a few community Bolt drivers that are up-to-date.

Let me know if you have more questions!

Hi, can you share a few points as to why Bolt driver is preferred over http? Thanks.

Generally speaking, the Bolt protocol implemented by the drivers includes a richer feature set than the one offered by the available HTTP REST APIs.

For instance, you get:

  • automatic retries with transaction functions
  • rich type support (including temporal and geospatial types)
  • routing support
  • bookmark support for causal clusters

If you are also part of polyglot Neo4j-based projects, you will be able to switch more easily from one project to the other, as drivers strive for exposing an homogeneous API across languages.

We are currently working on updating https://neo4j.com/docs/driver-manual/current/ but it is definitely worth a read!

Thanks for this question and insight into the HTTP API vs. Driver. I have the same question but came up against these issues. I am creating an API that will communicate with Neo4j on the backend, and a frontend app that includes graph visualizations.

  • I want data returned with the resultDataContents set to graph because I need data in a format compatible with javascript visualization libraries. This is not a parameter that can be set in the driver (explained why not here) but it can be set over HTTP API.

  • For reasons other than visualizations, I need to access Neosemantics endpoints I've set in my Neo4j, i.e. /rdf. In the Neo4j Browser I can send :GET or :POST Cypher commands, which are really just shortcuts for HTTP requests to the /rdf endpoint (explained here). But in the drivers those cypher commands do not work.

So I concluded my project would be best built using requests to the HTTP API and Neosemantics endpoints, rather than the driver. I understand this is a specific case but I was curious if this seems like a bad design given your opposite recommendation! Thanks! This is my first Neo4j project so I have a lot to learn. @lingvisa @florent.biville1

@marlo The access to Neosemantics is definitely a very good reason to stick to HTTP endpoints, so your choice of sticking to HTTP completely makes sense to me.