@graphistry/client-api

中文文档
5.1.8发布于 2025/07/17Apache-2.0ESM + CJS近 30 天下载 7103

Client-side API for interacting with a Graphistry embedded visualization.

原始使用文档
文档目录6 节
  1. Graphistry's client-side interactions API makes it easy for…
  2. Installation
  3. Docs
  4. Import
  5. Dual usage modes
  6. Uploads

Graphistry's JavaScript Client API

Graphistry's client-side interactions API makes it easy for developers to interact with embedded graph visualizations.

Installation

The JS package supports commonjs, esm, and iffe formats. See package.json for dist/ folder contents.

The rxjs version is an unpinned peer dependency:

  • The bundled versions dist/index.{cjs,esm,iife}.min.js keep rxjs as an external package
  • The bundled versions dist/index.full.{cjs,esm,iife}.min.js include it
  • Use dist/index.full.iife.min.js for <script src="..."/> tags

Docs

  1. To use this interactions API, call GraphistryJS with an IFrame containing a graphistry vizualization
  2. See client-api (interactive storybook docs)
  3. Refer to the Graphistry class for a list of the methods currently supported. More on the way!
  4. Refer to example in GraphistryJS

See also the @graphistry/client-api-react React docs

Import

Depending on the module format, you may use import, require, and window.GraphistryModule:

const G = GraphistryModule;
const g = G.graphistryJS(elt);
import { graphistryJS } from '@graphistry/client-api';
const g = graphistryJS(elt);
const G = require('@graphistry/client-api');
const g = G.graphistryJS(elt);

Dual usage modes

The library exposes two calling conventions to choose from.

RxJS orchestrations

const G = GraphistryModule;
document.addEventListener("DOMContentLoaded", function () {

    var g = G.graphistryJS(document.getElementById('viz'));
    var sub = g.pipe(
            G.tap(() => console.log('GraphistryJS ready instance as window.g')),
            G.delay(5000),
            G.addFilter('point:degree > 1'),
            G.updateSetting('background', '#FF0000')
        )
        .subscribe(
            function () {},
            function (err) { console.error('exn on setup', err); },
            function () { console.log('finished setup'); });

    //Optional: sub.unsubscribe() to cancel

});

Async commands

const G = GraphistryModule;
document.addEventListener("DOMContentLoaded", function () {

    var g = G.graphistryJS(document.getElementById('viz'));
    g.pipe(
        G.tap(() => {

            //non-rxjs on ready g
            console.log('GraphistryJS ready instance as window.g');
            setTimeout(
                () => {
                    g.addFilter();
                    g.updateSetting('background', '#FF0000');
                },
                5000);

        }))
        .subscribe();

});

Uploads

You can also use the library to configure & upload visualization data, and get back dataset IDs to embed as a live visualization:

import { Client, Dataset, File, EdgeFile, NodeFile } from '@graphistry/client-api';

//defaults: 'https', 'hub.graphistry.com', 'https://hub.graphistry.com'
const client = new Client('my_username', 'my_password');

//columnar data is fastest; column per attribute; reuse across datasets
const edgesFile = new EdgeFile({'s': ['a1', 'b2'], 'd': ['b2', 'c3']});
const nodesFile = new NodeFile({'n': ['a1', 'b2', 'c3'], 'a1': ['x', 'y', 'z']});

const dataset = new Dataset({
    node_encodings: { bindings: { node: 'n' } },
    edge_encodings: { bindings: { source: 's', destination: 'd' } },
    metadata: {},
    name: 'testdata',
}, edgesFile, nodesFile);

await dataset.upload();
console.info(`View at ${dataset.datasetID} at ${dataset.datasetURL}`);

See additional examples in the @graphistry/node-api docs or API references here

版本与发布记录

@graphistry/client-api 共发布 89 个版本,首次发布于 2017/05/17;过去 12 个月发布了 0 个版本。

版本发布日期距今
5.1.8latest2025/07/171.3 年前
5.1.72025/07/171.3 年前
5.1.62025/07/101.4 年前
5.1.52025/06/181.4 年前
5.1.42025/05/301.5 年前
5.1.32025/05/221.5 年前

关于 @graphistry/client-api 的常见问题

@graphistry/client-api 是什么?

Client-side API for interacting with a Graphistry embedded visualization.

如何安装 @graphistry/client-api?

在项目目录运行 npm install @graphistry/client-api,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:rxjs(>=7.2.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@graphistry/client-api 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/graphistry__client-api 是否存在。

@graphistry/client-api 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@graphistry/client-api 可以商用吗?

@graphistry/client-api 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@graphistry/client-api 的下载量有多少?

根据 npm 官方下载统计,@graphistry/client-api 在 2026/10/17 – 2026/11/15 这 30 天内被下载 7,103 次,日均约 237 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@graphistry/client-api 还在维护吗?

最新版本 5.1.8 发布于 2025/07/17(1.3 年前);至今共发布 89 个版本,其中过去 12 个月发布了 0 个;首次发布于 2017/05/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。