REST APIs for SAS Viya
Getting started with REST APIs for SAS Viya
SAS Viya REST APIs are designed for enterprise application developers, who intend to build on the work of model builders and data scientists, to deliver apps based on SAS Viya technology. With SAS REST APIs, you can create and access SAS resources using any client technology.
>> Access to SAS Cloud Analytic Services (CAS) REST APIs - for analysts and data scientists
SAS Viya REST API reference
Explore the capabilities of SAS Viya APIs
SAS Viya REST APIs on GitHub
GitHub repositorities supporting SAS Viya REST APIs
SAS Viya REST API repositories
pyviyatools
Python command-line tools that call the SAS Viya REST APIs - for SAS administrators.
>> pyviyatools YouTube tutorial
restaf
A simple framework for building applications with SAS REST APIs, supported with SAS Viya.
restaf-demos
A collection of examples using restaf in a nodejs environment.
restaf-apiexplorer
A complete web application using restaf to explore SAS REST APIs.
restaf-server
restaf-server is a server designed specifically to work with SAS Viya.
restaf-uicomponents
React components for SAS Viya applications built using restaf.
restaf-uidemos
Examples of SAS Viya Applications built with restaf.
restlib
Python module to build REST interfaces.
Join the conversation!
Ask, find and share on the SAS Developers Community
Sample code
The sample code below performs an HTTP POST request generate a report image. To see further sample code, visit the samples page on GitHub.
Generate and View Report Image
HTTP POST request to generate a report image
POST /reportImages/jobs?wait=30&requestLogLevel=DEBUG
{"_comment": "Request body"
"version" : 1,
"reportUri" : "/reports/reports/{{reportid}}",
"layoutType" : "entireSection",
"size" : "400x300",
"refresh": false
}
# Response application/vnd.sas.report.images.job+json
{
"id": "d8ace882-29e1-4223-baf5-0ffa8cea350e",
"version": 2,
"links": [
{
"method": "GET",
"rel": "self",
"href": "/reportImages/jobs/d8ace882-29e1-4223-baf5-0ffa8cea350e",
"uri": "/reportImages/jobs/d8ace882-29e1-4223-baf5-0ffa8cea350e",
"type": "application/vnd.sas.report.images.job"
},
{
"method": "GET",
"rel": "state",
"href": "/reportImages/jobs/d8ace882-29e1-4223-baf5-0ffa8cea350e/state",
"uri": "/reportImages/jobs/d8ace882-29e1-4223-baf5-0ffa8cea350e/state",
"type": "text/plain"
},
{
"method": "POST",
"rel": "renderAll",
"href": "/reportImages/jobs?selectionType=report&size=900x600&reportUri=/reports/reports/23f2183d-48f5-42e8-a7d9-f40281c3fac4&layoutType=entireSection&refresh=true",
"uri": "/reportImages/jobs?selectionType=report&size=900x600&reportUri=/reports/reports/23f2183d-48f5-42e8-a7d9-f40281c3fac4&layoutType=entireSection&refresh=true",
"type": "application/vnd.sas.report.images.job"
}
],
"state": "running",
"creationTimeStamp": "2019-11-11T20:29:16.733Z"
}
# Next get the report image name
GET /reportImages/jobs/d8ace882-29e1-4223-baf5-0ffa8cea350e
# Response application/vnd.sas.report.images.job+json
{
"id": "d8ace882-29e1-4223-baf5-0ffa8cea350e",
"version": 2,
"links": [
{
"method": "GET",
"rel": "self",
"href": "/reportImages/jobs/d8ace882-29e1-4223-baf5-0ffa8cea350e",
"uri": "/reportImages/jobs/d8ace882-29e1-4223-baf5-0ffa8cea350e",
"type": "application/vnd.sas.report.images.job"
},
{
"method": "GET",
"rel": "state",
"href": "/reportImages/jobs/d8ace882-29e1-4223-baf5-0ffa8cea350e/state",
"uri": "/reportImages/jobs/d8ace882-29e1-4223-baf5-0ffa8cea350e/state",
"type": "text/plain"
},
{
"method": "POST",
"rel": "renderAll",
"href": "/reportImages/jobs?selectionType=report&size=900x600&reportUri=/reports/reports/23f2183d-48f5-42e8-a7d9-f40281c3fac4&layoutType=entireSection&refresh=true",
"uri": "/reportImages/jobs?selectionType=report&size=900x600&reportUri=/reports/reports/23f2183d-48f5-42e8-a7d9-f40281c3fac4&layoutType=entireSection&refresh=true",
"type": "application/vnd.sas.report.images.job"
}
],
"state": "completed",
"duration": 2.213,
"creationTimeStamp": "2019-11-11T20:29:16.733Z",
"images": [
{
"sectionIndex": 0,
"sectionName": "vi6",
"sectionLabel": "Page 1",
"elementName": "vi6",
"visualType": "Section",
"size": "900x600",
"state": "completed",
"modifiedTimeStamp": "2019-11-11T20:29:18.932Z",
"links": [
{
"method": "GET",
"rel": "image",
"href": "/reportImages/images/K1870020424B677273814.svg",
"uri": "/reportImages/images/K1870020424B677273814.svg",
"type": "image/svg+xml"
},
{
"method": "POST",
"rel": "render",
"href": "/reportImages/jobs?selectionType=visualElements&size=900x600&reportUri=/reports/reports/23f2183d-48f5-42e8-a7d9-f40281c3fac4&layoutType=entireSection&refresh=true&visualElementNames=vi6",
"uri": "/reportImages/jobs?selectionType=visualElements&size=900x600&reportUri=/reports/reports/23f2183d-48f5-42e8-a7d9-f40281c3fac4&layoutType=entireSection&refresh=true&visualElementNames=vi6",
"type": "application/vnd.sas.report.images.job"
},
{
"method": "POST",
"rel": "resize",
"href": "/reportImages/jobs?selectionType=visualElements&reportUri=/reports/reports/23f2183d-48f5-42e8-a7d9-f40281c3fac4&layoutType=entireSection&refresh=true&visualElementNames=vi6&size={size}",
"uri": "/reportImages/jobs?selectionType=visualElements&reportUri=/reports/reports/23f2183d-48f5-42e8-a7d9-f40281c3fac4&layoutType=entireSection&refresh=true&visualElementNames=vi6&size={size}",
"type": "application/vnd.sas.report.images.job"
}
]
}
]
}
# And finally, retrieve the image
GET //reportImages/images/K1870020424B677273814.svg
# Response image/svg+xml