REST APIs for Cloud Analytics Services (CAS)

Getting started with REST APIs for Cloud Analytics Services (CAS)

The CAS REST APIs are for data scientists, programmers and administrators, who need to interact with CAS directly and know about CAS actions. There are API operations for executing CAS actions, managing the CAS sessions, monitoring the system and inspecting the CAS grid.

>> Access to SAS Viya REST APIs - for application developers and admins

CAS Actions
SAS Viya uses CAS to perform tasks. The smallest unit of work for the CAS server is a CAS action. CAS actions can load data, transform data, compute statistics, perform analytics and create output. Each action is configured by specifying a set of input parameters. Running a CAS action in the CAS server processes the action's parameters and the data and creates an action result. For more information, see “Programming with CAS Actions” in An Introduction to SAS Viya Programming.

SAS Viya provides a variety of interfaces for running CAS actions, including the following:

  • from a SAS session using the CAS procedure. The CAS procedure uses the CASL language for specifying CAS actions and their input parameters. CASL also supports normal program logic such as conditional and looping statements and user-written functions.
  • from Python, R or Lua using the SAS Scripting Wrapper for Analytics Transfer (SWAT) libraries.
  • from Java using the CASClient class.
  • via REST using the CAS REST APIs.

Sample code

The sample code below performs an HTTP POST to retrieve basic statistics from a SAS table.

Fetch Simple Statistics


# HTTP POST request to retrieve simple statistics from a SAS table

POST /cas/sessions/{{sessionid}}/actions/simple.summary

# Request body
{
	"table":{"caslib":"PUBLIC","name":"FLIGHT_DATA","groupBy":{"name":"manufacturer"}},
	"casout":{"caslib":"PUBLIC","name":"airbusdata2","promote":true,"where":"Manufacturer='AIRBUS'"}
}

# Response application/json
{
  "status": 0,
  "results": {
    "OutputCasTables": {
      "_ctb": true,
      "label": "",
      "title": "Output CAS Tables",
      "name": "OutputCasTables",
      "schema": [
        {
          "name": "casLib",
          "label": "CAS Library",
          "format": "",
          "type": "string",
          "width": 6,
          "attributes": {}
        },
        {
          "name": "Name",
          "label": "Name",
          "format": "",
          "type": "string",
          "width": 11,
          "attributes": {}
        },
        {
          "name": "Rows",
          "label": "Number of Rows",
          "format": "",
          "type": "int",
          "width": 8,
          "attributes": {}
        },
        {
          "name": "Columns",
          "label": "Number of Columns",
          "format": "",
          "type": "int",
          "width": 8,
          "attributes": {}
        }
      ],
      "attributes": {
        "Action": {
          "type": "string",
          "value": "summary"
        },
        "Actionset": {
          "type": "string",
          "value": "simple"
        },
        "CreateTime": {
          "type": "double",
          "value": 1887896285.03759
        }
      },
      "rows": [
        [
          "Public",
          "airbusdata2",
          3,
          19
        ]
      ]
    }
  },
  "logEntries": [
    {
      "message": "WARNING: License for feature 'CRSSTAT Action Set for Common Code' has expired and will stop working in 0 days. Contact your installation representative to obtain a renewal.",
      "level": "warn"
    },
    {
      "message": "WARNING: License for feature 'TKCAS SAS Cloud Analytic Services Server' has expired and will stop working in 0 days. Contact your installation representative to obtain a renewal.",
      "level": "warn"
    }
  ],
  "disposition": {
    "severity": "Warning",
    "reason": "OK",
    "statusCode": 0,
    "formattedStatus": null,
    "debugInfo": null
  },
  "changedResources": [
    "tables"
  ],
  "metrics": {
    "elapsedTime": 0.007451,
    "cpuUserTime": 0.003,
    "cpuSystemTime": 0.002999,
    "systemTotalMemory": 135332311040,
    "systemNodes": 1,
    "systemCores": 10,
    "memory": 2194336,
    "osMemory": 11063296,
    "systemMemory": 0,
    "memoryQuota": 11587584,
    "ioPageReclaims": 0,
    "ioPageFaults": 0,
    "ioReadFaults": 0,
    "ioReadBlocks": 0,
    "ioReadCalls": 0,
    "ioWriteCalls": 0,
    "ioReadBytes": 0,
    "ioWriteBytes": 0,
    "ioWriteBytesCancelled": 0,
    "voluntaryContextSwitches": 0,
    "involuntaryContextSwitches": 0,
    "dataMovementBytes": 0
  }
}