API

Our API is allows you to use BlockScript Functions within your app. We currently only have one endpoint, unique to each Function. You can find this by following these steps:

  • Navigate to the Function you would like to call over the API
  • Enable 'Cloud Execution'. Note: you must have a premium account
  • Enable 'REST API'
  • Copy the 'Function Url' using the copy button. https://blockscript.app/api/function?functionID={{MYFUNCTIONID}}
  • Copy the 'API Key' using the copy button. Note: API Keys are unique to each Function

</br> <img src="/assets/images/enableApi.png" /> </br>

Authenticating Requests

BlockScript uses API keys to authenticate its API. To authenticate your request with your API key, set the x-api-key header value to your API key.

</br>

Regenerate your API Key ⚠️

If you want to stop the current API Key from accessing your Function you can regenerate the API key using the 'Regenerate API Key' button. Please be aware that this will cause the current API key to stop working, this is irreversible and cannot be undone.

</br>

Example Request

Below is an example of a request in Postman, the Function being executed is the start example below:

<img width="700" src="/assets/images/api/function.png" />

The method is set POST, and the Url to the 'Function Url' from the 'Settings' menu in the sidebar.

<img width="800" src="/assets/images/api/apikeyandurl.png" />

The API Key is also set using the x-api-key header. If this is incorrect, or not set this will result in a status code of 401.

<br/>

Parameters

This Function has one Parameter called 'String'. This is provided in JSON format as the body of the request:

<img width="800" src="/assets/images/api/body.png" />

<br/>

Running the Function

If all is setup correctly, the Function will return the result as below:

<img width="900" src="/assets/images/api/result.png" />

If an error occurs the result will provide you with the error message and reason:

<img width="500" src="/assets/images/api/error.png" />