BookmarkSubscribeRSS Feed

Jump Start a REST API server for your SAS Viya programs

Started ‎03-12-2021 by
Modified ‎03-12-2021 by
Views 7,945


Hi fellow SAS Viya Programmers - Do you want to enable your users to access your SAS programs using REST API? Do you want to deliver your programs in a container? Then read on!



This article presents an easy way for SAS programmers to create a REST API server to front their SAS Viya Programs - including data steps, procedures, CAS Actions or CASL programs.


Full documentation for the create-viya-api tool is located on GitHub. Additionally, please follow this link if you'd like to see the details of the underlying server code. The entire project is based on restaf - An Easy Button To Access SAS Viya Using SAS Viya REST APIs.


Below is a short introductory video demonstrating the functionality.



Key Features


  1. Define your API end points using JavaScript

  2. Authentication

    • Accepts a valid SAS Viya token
    • If called from an authenticated browser session it will get a token from SAS Viya
    • By design it does not support client credentials(userid, password) - since bullets 1 and 2 are the more common use cases.
  3. In your handler (where you process the request), you have access to a context object with the following:

    • The current valid token
    • All the standard http artifacts - path, query, payload, headers etc
    • Access the REST end points via swagger, web applications and any scripting environment
  4. Deploy the server in a Docker container

  5. The starter example has the following end points to jump start your development. These cover some basic scenarios.

    • CAS actions
    • CASL statements
    • Compute service with the user-supplied code
    • Specific program saved in the "server". In this example, the code is in a file on the API server, but in a real deployment this code will be in some repository


Next Steps

Please try it out for yourself. And be sure to send your feedback - good or bad. 


SAS Documentation

Please refer to the SAS Support site for full documentation.

Version history
Last update:
‎03-12-2021 11:15 AM
Updated by:


Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.


Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags