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 → Configuration settings dbms.rest.transaction.idle_timeout to the number of seconds before timeout. The default timeout is 60 seconds.

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.

  • Literal line breaks are not allowed inside Cypher statements.

  • Cypher queries with USING PERIODIC COMMIT (see Cypher Manual → PERIODIC COMMIT query hint) may only be executed when creating a new transaction and immediately committing it with a single HTTP request (see 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 Cypher Manual → Parameters for more information.