Intro to GraphXR API

GraphXR API is a JavaScript library for GraphXR. If you can do it in the GUI, you can do it with the API.

See the reference for examples.


There are a few ways to use GraphXR API.

1. In Grove

📽️ 1m tutorial: Hello, Grove (opens in a new tab)

  1. In a GraphXR project, open the Grove extension
  2. Create a new Grovebook
  3. Start editing 🎉. You can use the synchronous API: gxr. i.e. as opposed to await gxr()

2. With the iframe adapter

  1. Create a new HTML file
  2. Add the following code to the file
<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script type="module">
      import gxr from "";
        .addEventListener("load", async () => {
          // Wait a few seconds for GraphXR to load.
          console.log("Loading GraphXR...");
          setTimeout(async () => {
            console.log("GraphXR loaded!")
            await gxr().graph().generate().sleep(3000).forceLayout();
          }, 3000);

The pattern to use graphxr-api-iframe is await gxr() and then chain the API functions to that.

Check out concepts, snippets, and the reference.

3. On ObservableHQ, with the iframe adapter

See this example (opens in a new tab).

Example of the GraphXR API iframe adapter