Symbol OpenAPI TypeScript Fetch Client

1.0.3 · abandoned · verified Tue Apr 21

This package, `symbol-openapi-typescript-fetch-client` (version 1.0.3, last published in November 2021), provides a generated OpenAPI client for the Symbol blockchain. It is built using `symbol-openapi-generator` and designed to interact with Symbol nodes via the standard `fetch` API. It ships with TypeScript types, offering type-safe access to Symbol's REST API endpoints as defined by its OpenAPI specification at the time of its generation. However, it's crucial to note that this package is essentially an artifact generated from an older specification and generator. The README itself points users to `symbol-sdk-typescript-javascript`, which has since been deprecated (as of January 2022). For current Symbol blockchain development, the actively maintained `@symbol/symbol-sdk` package should be used instead, as this generated client is not regularly updated and reflects an outdated state of the Symbol ecosystem.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to initialize the generated Symbol OpenAPI client and fetch basic information about a Symbol node, including its health status and general details.

import { Configuration, NodeRoutesApi } from 'symbol-openapi-typescript-fetch-client';

async function getNodeHealthStatus() {
  // For Node.js versions < 18, you might need a polyfill:
  // import fetch from 'node-fetch';
  // globalThis.fetch = fetch as any; 

  const nodeUrl = process.env.SYMBOL_NODE_URL ?? 'http://localhost:3000';

  try {
    const config = new Configuration({ 
      basePath: nodeUrl,
      // You can add headers, API keys, or other configurations here
      // For example, for a public node, no specific auth is usually needed for node info.
    });
    const nodeApi = new NodeRoutesApi(config);

    // Fetch the node info
    const nodeInfo = await nodeApi.getNodeInfo();
    console.log('Node Info:', nodeInfo);

    // Fetch the node health status
    const healthStatus = await nodeApi.getNodeHealth();
    console.log('Node Health Status:', healthStatus);

  } catch (error) {
    console.error('Error fetching Symbol node information:', error);
    if (error instanceof TypeError && error.message.includes('fetch is not defined')) {
      console.error('Hint: In Node.js environments, ensure `fetch` is available. For Node.js < 18, install `node-fetch` and polyfill `globalThis.fetch`.');
    }
  }
}

getNodeHealthStatus();

view raw JSON →