CalcTree's API allows you to get even more value out of your calculation pages by allowing you to integrate them into your external workflows.
Currently, CalcTree's API is read-only. Here's a quick summary what you can and can't do with the API in it's current state:
What can you do with the API ✅
What can’t you do with the API ❌
API Key
Before you can use the CalcTree API, you need to generate an API key. To do so, follow these steps:
1. Clicking on "Settings & Members" in the top left corner of the CalcTree page
2. In the settings page, locate and click "API keys" in the top left corner
3. Click "Create API key" to create a new API key
4. A popup will appear, prompting you for the key name
Once you've given a name, please save the generated key securely. You won't be able to view this token key again.
Turning on API integration
Before you can start using the CalcTree API, you need to enable API integration. To do so, go to the calculation page that you would like to use. On the right, you will see a sidebar.
On the top right corner of the sidebar, click [+ Add]
Next, click on the API integration button
Now, your API has been added. Click on the arrow next to it and expand the details
From here, you can obtain the current page ID, which you will need to send a request
Using the API with Python without dependencies
CalcTree python client
GrassHopper integration 🔌
Below are two examples of integrating CalcTree with Grasshopper. The first example utilises Python without relying on any external dependencies, while the second one employs the CalcTree client. In both examples, all you need to do is set:
CALC_TREE_API_KEY - paste your API key
PAGE_ID - paste your Page ID
input_params - set your input params
Finally, define your output by modifying this line:
script_output = next(item for item in res if item['param'] == 'YOUR OUTPUT PARAM NAME')