Scripts 🔗

All datasets link to a scripts catalog where the index of automation scripts that have been successfully executed are listed.

{
   "element": "shoji:entity",
   "self": "https://app.crunch.io/api/datasets/123456/",
   "body": {
      "name": "My new project",
      //...
   },
   "catalogs: {
      // ...
      "scripts": "https://app.crunch.io/api/datasets/123456/scripts/"
      // ...
   }
}
GET /api/datasets/123456/scripts/ HTTP/1.1

{
    "element": "shoji:catalog",
    "self": "https://app.crunch.io/api/datasets/123456/scripts/",
    "index": {}
}

Creating and executing scripts 🔗

By default all datasets start with an empty script’s catalog. Creating new scripts via POST will populate them.

POST /api/datasets/123456/scripts/ HTTP/1.1

{
    "element": "shoji:entity",
    "body" {
        "body": "<Script contents>"
    }
}

The server will perform a synchronous validation of the script’s contents and consistency against the current dataset’s schema. In case of error, the server will return a 400 error response with a crunch:error as the body containing the list of errors.

{
    "element": "crunch:error",
    "self": "https://app.crunch.io/api/datasets/123456/scripts/",
    "type": "scripts:syntax",
    "description": "Errors processing the script",
    "resolutions": [
       {
           "line": 0,
           "line": 0,
           "command": 0,
           "message": ""
       },
       {
           "line": 0,
           "line": 0,
           "command": 0,
           "message": ""
       },
       // ...
    ]
}

The errors will be under the resolutions key containing a list of errors descriptions indicating the command number, and script line and column where for each error.

In the case of a successful validation, the server will return a 202 response with a shoji:view response body pointing to a progress indicator to follow the script’s execution status.

The dataset remains locked for changes during this script execution period.