Links

Node.js SDK

The Node.js SDK spice.js is the easiest way to use and query Spice.xyz with Node.js.
It uses Apache Apache Flight to efficiently stream data to the client and Apache Arrow Records as data frames which are then easily converted to JavaScript objects/arrays or JSON.

Requirements

Installation

npm install @spiceai/spice --save
or
yarn add @spiceai/spice

Usage

Import SpiceClient and instantiate a new instance with an API Key.
You can then submit queries using the query function.
import { SpiceClient } from "@spiceai/spice";
const spiceClient = new SpiceClient("API_KEY");
const table = await spiceClient.query(
'SELECT number, "timestamp", gas_used FROM eth.recent_blocks LIMIT 10'
);
console.table(table.toArray());
SpiceClient has the following arguments:
  • apiKey (string, required): API key to authenticate with the endpoint.
  • url (string, optional): URL of the endpoint to use (default: flight.spiceai.io:443)

Contributing

Contribute to or file an issue with the Spice.js library at https://github.com/spiceai/spice.js
Last modified 4mo ago