SureSheet Collab API
  • Introduction
  • Python examples
  • Python + requests example
  • JavaScript examples
  • Web app example
Powered by GitBook
On this page
  • Simple example
  • Advanced example with ranges

JavaScript examples

PreviousPython + requests exampleNextWeb app example

Last updated 2 years ago

These examples use the SureSheet.

Simple example

(async () => {
    const workbookId = "abc7cbef-2491-4787-94f8-6542fab12a4e";
    const simulateUrl = `https://www.equalto.com/suresheet/api/v1/simulate/${workbookId}`;
    const response = await fetch(simulateUrl, {
        method: 'POST',
        body: JSON.stringify({
            inputs: {
                Sheet1: {
                    C6: 25000,
                },
            },
            outputs: {
              Sheet1: ['C13'],
            },
        }),
        headers: {
            'Content-Type': 'application/json',
        },
    });
    const responseJson = await response.json();
    console.log(responseJson)
})();

Should print:

{'Sheet1': {'C13': 50783.31719489607}}

Advanced example with ranges

(async () => {
    const workbookId = "abc7cbef-2491-4787-94f8-6542fab12a4e";
    const simulateUrl = `https://www.equalto.com/suresheet/api/v1/simulate/${workbookId}`;
    const response = await fetch(simulateUrl, {
        method: 'POST',
        body: JSON.stringify({
            inputs: {
                Sheet1: {
                    C6: 25000,
                },
            },
            outputs: {
              Sheet1: ['C13', 'B14:C16'],
            },
        }),
        headers: {
            'Content-Type': 'application/json',
        },
    });
    const responseJson = await response.json();
    console.log(responseJson)
})();

Should print:

{
    "Sheet1": {
        "C13": 50783.31719489607,
        "B14:C16": [
            [
                "   Initial investment amount:",
                25000.0
            ],
            [
                "   Additional contributions:",
                10500.0
            ],
            [
                "   Interest earned:",
                15283.31719489607
            ]
        ]
    }
}
Investment Growth Calculator