LogoFreestyle
API ReferenceExecute

Execute Code

Send a TypeScript or JavaScript module, get the result

POST
/execute/v1/script

Request Body

application/json

script*string

The JavaScript or TypeScript script to execute

config?

Response Body

application/json

application/json

application/json

curl -X POST "https://api.freestyle.sh/execute/v1/script" \  -H "Content-Type: application/json" \  -d '{    "script": "export default () => {\n  // get the value of the factorials of the numbers from 1 to 10 combined\n  const a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n\n  function factorial(n) {\n    if (n === 0) {\n      return 1;\n    }\n    return n * factorial(n - 1);\n  }\n\n  const b = a.map(factorial);\n\n  return b.reduce((a, b) => a + b);\n};\n"  }'
{
  "result": null,
  "logs": [
    {
      "message": "I'm a log!",
      "type": "log"
    }
  ]
}
{
  "error": "string",
  "logs": [
    {
      "message": "I'm a log!",
      "type": "log"
    }
  ]
}
{
  "error": "string",
  "logs": [
    {
      "message": "I'm a log!",
      "type": "log"
    }
  ]
}

Freestyle AI

Documentation assistant

Experimental: AI responses may not always be accurate—please verify important details with the official documentation.

How can I help?

Ask me about Freestyle while you browse the docs.