cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Should I use HTTP API or Driver API?

lingvisa
Graph Fellow
  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?

6 REPLIES 6

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.

bryant
Node Clone

I use the HTTP API a lot due to its flexibility. I do a lot with Power Query and Power BI with graph data from Neo4j and the only way to get automatic refreshes in the Power BI online service for Neo4j-based data is to use the REST API. I will say that the REST API for Neo4j is a bit of a mess. It's probably one of the worst REST API's I've worked with, but once you understand it, you can control and manipulate it how you need.
Some of this is documented in a blog post I did where it shows how what you get from the Neo4j browser when running Cypher queries is not the same thing you get when you use the REST API. Also Neo4j's REST API does not return standardized results. Meaning you get entirely different JSON structures back, depending on the Cypher Query your write.
So you end up having to be better at writing deliberate Cypher queries to get exactly what you from the HTTP API.
Once you get used to it, I find the HTTP API decent to work with - just a bit frustrating.
The other API's do have similar issues also. For example the .Net API requires you to write specific types of queries based on the formatted results coming back from Neo4j Also.

I hope that helps a bit. Here's a link to an article I wrote interfacing Power BI using the HTTP REST API: