Python examples
These examples use the Investment Growth Calculator SureSheet, and do not depend on any third-party libraries.
Simple example
import urllib.request
from urllib.parse import quote
import json
workbook_id = "abc7cbef-2491-4787-94f8-6542fab12a4e"
inputs = json.dumps({"Sheet1":{"C6":25000}})
outputs = json.dumps({"Sheet1":["C13"]})
simulate_url = f"https://www.equalto.com/suresheet/api/v1/simulate/{workbook_id}?inputs={quote(inputs)}&outputs={quote(outputs)}"
with urllib.request.urlopen(simulate_url) as response:
results = json.loads(response.read())
print(results)
Should print:
{'Sheet1': {'C13': 50783.31719489607}}
Advanced example with ranges
import urllib.request
from urllib.parse import quote
import json
workbook_id = "abc7cbef-2491-4787-94f8-6542fab12a4e"
inputs = json.dumps({"Sheet1":{"C6":25000}})
outputs = json.dumps({"Sheet1":["C13", "B14:C16"]})
simulate_url = f"https://www.equalto.com/suresheet/api/v1/simulate/{workbook_id}?inputs={quote(inputs)}&outputs={quote(outputs)}"
with urllib.request.urlopen(simulate_url) as response:
results = json.loads(response.read())
print(json.dumps(results, indent=4))
Should print:
{
"Sheet1": {
"C13": 50783.31719489607,
"B14:C16": [
[
" Initial investment amount:",
25000.0
],
[
" Additional contributions:",
10500.0
],
[
" Interest earned:",
15283.31719489607
]
]
}
}
Last updated