Need help with arangojs?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

530 Stars 102 Forks Apache License 2.0 1.7K Commits 17 Opened issues


The official ArangoDB JavaScript driver.

Services available


Need anything else?

Contributors list

ArangoDB JavaScript Driver

The official ArangoDB JavaScript client for Node.js and the browser.

license - APACHE-2.0 Continuous Integration

npm package status



With npm or yarn

npm install --save arangojs
## - or -
yarn add arangojs

For browsers

When using modern JavaScript tooling with a bundler and compiler (e.g. Babel), arangojs can be installed using

like any other dependency.

For use without a compiler, the npm release comes with a precompiled browser build for evergreen browsers and Internet Explorer 11:

var arangojs = require("arangojs/web");

You can also use unpkg during development:

< !-- note the path includes the version number (e.g. 7.0.0) -- >

If you are targetting browsers older than Internet Explorer 11 you may want to use babel with a polyfill to provide missing functionality needed to use arangojs.

When loading the browser build with a script tag make sure to load the polyfill first:

Basic usage example

Modern JavaScript/TypeScript with async/await:

// TS: import { Database, aql } from "arangojs";
const { Database, aql } = require("arangojs");

const db = new Database(); const Pokemons = db.collection("my-pokemons");

async function main() { try { const pokemons = await db.query(aql FOR pokemon IN ${Pokemons} FILTER pokemon.type == "fire" RETURN pokemon ); console.log("My pokemons, let me show you them:"); for await (const pokemon of pokemons) { console.log(; } } catch (err) { console.error(err.message); } }


Using a different database:

const db = new Database({
  url: "http://localhost:8529",
  databaseName: "pancakes",
  auth: { username: "root", password: "hunter2" },

// The database can be swapped at any time db.useDatabase("waffles"); db.useBasicAuth("admin", "maplesyrup");

Old-school JavaScript with promises:

var arangojs = require("arangojs");
var Database = arangojs.Database;

var db = new Database(); var pokemons = db.collection("pokemons");

db.query({ query: "FOR p IN @@c FILTER p.type === 'fire' RETURN p", bindVars: { c: pokemons }, }) .then(function (cursor) { console.log("My pokemons, let me show you them:"); return cursor.forEach(function (pokemon) { console.log(; }); }) .catch(function (err) { console.error(err.message); });

Note: The examples throughout this documentation use

and other modern language features like multi-line strings and template tags. When developing for an environment without support for these language features, substitute promises for
syntax as in the above example.


The arangojs driver is compatible with the latest stable version of ArangoDB available at the time of the driver release and remains compatible with the two most recent Node.js LTS versions in accordance with the official Node.js long-term support schedule.

For a list of changes between recent versions of the driver, see the CHANGELOG.

Note: arangojs is only intended to be used in Node.js or a browser to access ArangoDB from outside the database. If you are looking for the ArangoDB JavaScript API for Foxx or for accessing ArangoDB from within the

interactive shell, please refer to the documentation of the
and the

Error responses

If arangojs encounters an API error, it will throw an

with an
property indicating the ArangoDB error code and the
property indicating the HTTP status code from the response body.

For any other non-ArangoDB error responses (4xx/5xx status code), it will throw an

error with the status code indicated by the

If the server response did not indicate an error but the response body could not be parsed, a regular

may be thrown instead.

In all of these cases the server response object will be exposed as the

property on the error object.

If the request failed at a network level or the connection was closed without receiving a response, the underlying system error will be thrown instead.

Common issues

Missing functions or unexpected server errors

Please make sure you are using the latest version of this driver and that the version of the arangojs documentation you are reading matches that version.

Changes in the major version number of arangojs (e.g. 6.x.y -> 7.0.0) indicate backwards-incompatible changes in the arangojs API that may require changes in your code when upgrading your version of arangojs.

Additionally please ensure that your version of Node.js (or browser) and ArangoDB are supported by the version of arangojs you are trying to use. See the compatibility section for additional information.

Note: As of June 2018 ArangoDB 2.8 has reached its End of Life and is no longer supported in arangojs 7 and later. If your code needs to work with ArangoDB 2.8 you can continue using arangojs 6 and enable ArangoDB 2.8 compatibility mode by setting the config option

arangoVersion: 20800
to enable the ArangoDB 2.8 compatibility mode in arangojs 6.

You can install an older version of arangojs using

# for version 6.x.x
yarn add [email protected]
# - or -
npm install --save [email protected]

No code intelligence when using require instead of import

If you are using

to import the
module in JavaScript, the default export might not be recognized as a function by the code intelligence of common editors like Visual Studio Code, breaking auto-complete and other useful features.

As a workaround, use the

function exported by that module instead of calling the module itself:
  const arangojs = require("arangojs");

  • const db = arangojs({
  • const db = arangojs.arangojs({ url: ARANGODB_SERVER, });

Alternatively you can use the

class directly:
  const arangojs = require("arangojs");
  • const Database = arangojs.Database;
    • const db = arangojs({
    • const db = new Database({ url: ARANGODB_SERVER, });

    Or using object destructuring:

    - const arangojs = require("arangojs");
  • const { Database } = require("arangojs");
    • const db = arangojs({
    • const db = new Database({ url: ARANGODB_SERVER, });

    Error stack traces contain no useful information

    Due to the async, queue-based behavior of arangojs, the stack traces generated when an error occur rarely provide enough information to determine the location in your own code where the request was initiated.

    Using the

    configuration option, arangojs will attempt to always generate stack traces proactively when a request is performed, allowing arangojs to provide more meaningful stack traces at the cost of an impact to performance even when no error occurs.
      const { Database } = require("arangojs");

    const db = new Database({ url: ARANGODB_SERVER,

    • precaptureStackTraces: true, });

    Note that arangojs will attempt to use

    if available and fall back to generating a stack trace by throwing an error. In environments that do not support the
    property on error objects, this option will still impact performance but not result in any additional information becoming available.

    ReferenceError: window is not defined

    If you compile your Node project using a build tool like Webpack, you may need to tell it to target the correct environment:

    // webpack.config.js
    + "target": "node",

    To support use in both browser and Node environments arangojs uses the

    , to substitute browser-specific implementations for certain modules. Build tools like Webpack will respect this field when targetting a browser environment and may need to be explicitly told you are targetting Node instead.

    Node.js with self-signed HTTPS certificates

    If you need to support self-signed HTTPS certificates, you may have to add your certificates to the

    , e.g.:
      const { Database } = require("arangojs");

    const db = new Database({ url: ARANGODB_SERVER,

    • agentOptions: {

    • ca: [
    •   fs.readFileSync(".ssl/"),
    •   fs.readFileSync(".ssl/ca.pem")
    • ]
    • }, });

    Although this is strongly discouraged, it's also possible to disable HTTPS certificate validation entirely, but note this has extremely dangerous security implications:

      const { Database } = require("arangojs");

    const db = new Database({ url: ARANGODB_SERVER,

  • agentOptions: {

  • rejectUnauthorized: false
  • }, });

  • When using arangojs in the browser, self-signed HTTPS certificates need to be trusted by the browser or use a trusted root certificate.

    Streaming transactions leak

    When using the

    method it is important to be aware of the limitations of what a callback passed to this method is allowed to do.
    const collection = db.collection(collectionName);
    const trx = db.transaction(transactionId);

    // WARNING: This code will not work as intended! await trx.step(async () => { await; await; // Not part of the transaction! });

    // INSTEAD: Always perform a single operation per step: await trx.step(() =>; await trx.step(() =>;

    Please refer to the documentation of this method for additional examples.

    Streaming transactions timeout in cluster

    Example messages:

    transaction not found
    transaction already expired

    Transactions have different guarantees in a cluster.

    When using arangojs in a cluster with load balancing, you may need to adjust the value of

    to accommodate the number of transactions you need to be able to run in parallel. The default value is likely to be too low for most cluster scenarios involving frequent streaming transactions.

    Note: When using a high value for

    you may have to adjust the maximum number of threads in the ArangoDB configuration using the
    to support larger numbers of concurrent transactions on the server side.


    The Apache License, Version 2.0. For more information, see the accompanying LICENSE file.

    We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.