githubEdit

API Reference

SpiceClient(params)

The top-level object that connects to Spice.ai

  • params.api_key (string, optional): API key to authenticate with the endpoint

  • params.http_url (string, optional):

  • params.flight_url (string, optional): URL of the endpoint to use (default: localhost:50051, using local Spice Runtime)

Default connection to local Spice Runtime:

import { SpiceClient } from "@spiceai/spice";

const spiceClient = new Spiceclient();

Connect to Spice.AI Cloud Platform:

import { SpiceClient } from "@spiceai/spice";

const spiceClient = new Spiceclient({
    api_key: 'API_KEY',
    http_url: 'https://data.spiceai.io',
    flight_url: 'flight.spiceai.io:443'
});

Or using shorthand:

SpiceClient Methods

query(queryText: string, onData: (partialData: Tablearrow-up-right) => void) => Tablearrow-up-right

  • queryText: (string, required): The SQL query to execute

  • onData: (callback, optional): The callback function that is used for handling streaming data.

query returns an Apache Arrow Tablearrow-up-right.

To get the data in JSON format, iterate over each row by calling toArray()arrow-up-right on the table and call toJSON()arrow-up-right on each row.

Get all of the elements for a column by calling getChild(name: string)arrow-up-right and then calling toJSON() on the result.

Last updated

Was this helpful?