Client Class

Documentation

Client class

Client is the only class exported by the client API.

Constructor

The constructor takes a single argument, options, with two properties:

Property Description
options.baseUrl Server URL used by the Client and by the Jspreadsheet and Jworksheet objects created from it.
Defaults to the JSPREADSHEET_API_BASE_URL environment variable, then to "https://jspreadsheet.com/api".
options.token Access token for options.baseUrl. Optional, but services that require authentication will fail without it.

Methods

getSpreadsheet

Returns a Jspreadsheet object for the given spreadsheet guid.

Types

getSpreadsheet(guid: string): IJspreadsheet;

Description of properties

Property Description
guid Spreadsheet Guid.

Example

import { Client } from "@intrasheets/client";

const client = new Client({
    baseUrl: "[Server url]",
    token: "[Your access token]",
});

const spreadsheet = client.getSpreadsheet(
    "6b1842a1-f737-4492-b6c4-e54a25643fb7",
);

spreadsheet.getConfig().then((config) => console.log(config));

createSpreadsheet

Creates a spreadsheet and returns a Jspreadsheet object for it.

Types

createSpreadsheet(
    config: Omit<Spreadsheet, "worksheets"> & {
        worksheets: (Omit<Worksheet, "worksheetName"> &
            Required<Pick<Worksheet, "worksheetName">>)[];
    }
): Promise<IJspreadsheet>;

Description of properties

Property Description
config Spreadsheet Settings.

Note: a new spreadsheet must have at least one worksheet, and every worksheet must have a worksheetName.

Example

import { Client } from "@intrasheets/client";

const client = new Client({
    baseUrl: "[Server url]",
    token: "[Your access token]",
});

client
    .createSpreadsheet({
            worksheets: [
                {
                  minDimensions: [10, 10],
                  worksheetName: 'test'
                },
            ],
        })
    .then((spreadsheet) => {
        console.log(spreadsheet.getSpreadsheetGuid());
    });