Chapter 1. Introduction

The Neo4j transactional HTTP endpoint allows you to execute a series of Cypher statements within the scope of a transaction. The transaction may be kept open across multiple HTTP requests, until the client chooses to commit or roll back. Each HTTP request can include a list of statements, and for convenience you can include statements along with a request to begin or commit a transaction.

The server guards against orphaned transactions by using a timeout. If there are no requests for a given transaction within the timeout period, the server will roll it back. You can configure the timeout in the server configuration, by setting Operations Manual → dbms.rest.transaction.idle_timeout to the number of seconds before timeout. The default timeout is 60 seconds.

  • Literal line breaks are not allowed inside Cypher statements.
  • Open transactions are not shared among members of an HA cluster. Therefore, if you use this endpoint in an HA cluster, you must ensure that all requests for a given transaction are sent to the same Neo4j instance.
  • Cypher queries with USING PERIODIC COMMIT (see Section 6.5.5, “PERIODIC COMMIT query hint”) may only be executed when creating a new transaction and immediately committing it with a single HTTP request (see Section 2.1, “Begin and commit a transaction in one request” for how to do that).
  • When a request fails the transaction will be rolled back. By checking the result for the presence/absence of the transaction key you can figure out if the transaction is still open.

In order to speed up queries in repeated scenarios, try not to use literals but replace them with parameters wherever possible. This will let the server cache query plans. See Section 2.6, “Parameters” for more information.

Responses from the HTTP API can be transmitted as JSON streams, resulting in better performance and lower memory overhead on the server side. To use streaming, supply the header X-Stream: true with each request.