Skip to content

How to Use the API

To use the SRS API, you need to have a valid token. See authentication and execute the following GET/POST requests.

Definition

This api will return definition of SRS.

HTTP
GET {{host}}/api/srs/{{srs_id}}
Authorization: Token {{token}}

Execute

This api will execute the SRS and return the result in the specified format.

HTTP
GET {{host}}/api/srs/{{srs_id}}/{{renderer}}
Authorization: Token {{token}}

Note

  • Error in any command will return Http Status 200 with status = false and message = error message
  • Error in command with name srssetup will throw error message and the SRS will stop executing (This can be used to execute business logic before executing the SRS)

Parameters

When executing request, the parameters can be passed via query string, JSON body, or both.

Note

  • If a name is duplicated in the query string and JSON body, the query string will take precedence.
HTTP
1
2
3
4
5
6
7
8
POST {{host}}/api/srs/{{srs_id}}/{{renderer}}
Authorization: Token {{token}}
Content-Type: application/json

{
    "param1": "value1",
    "param2": "value2"
}

Renderers

The renderer is the format in which the SRS will be executed. The following renderers are supported:

  • /api/srs/{SRSID}/run - optimized JSON format (array of tables) for internal use
  • /api/srs/{SRSID}/{name}.json - JSON object, simplified format
  • /api/srs/{SRSID}/{name}.lower.json - JSON object, simplified format with lowercase property names
  • /api/srs/{SRSID}/{name}.html - all columns except those with ex="false"; empty commands and commands with types hidden or server are not exported
  • /api/srs/{SRSID}/{name}.xlsx - only columns with ex="false"; empty datasets and types hidden or server are not exported
  • /api/srs/{SRSID}/{name}.txt - raw data
  • /api/srs/{SRSID}/{name}.md - raw data with formatted tables
  • /api/srs/{SRSID}/{renderer}.hbs[.html|.pdf|.csv|.txt|.xml|.epp|.svg] - Handlebars templates A template is required in /template as file {renderer}.hbs
  • /api/srs/{SRSID}/{renderer}.frx[.html|.pdf] - Fast Report templates A template is required in /template as file {renderer}.frx

Extra query parameters

  • ptoken - authorization token; see authentication
  • pscope - comma-separated list of command names to limit execution to those commands.
  • popts - options passed to the renderer, in the format of comma-separated key=value pairs
    • links - generate links in HTML outputfrom standard SRS format
    • -nav
  • pcolumns - comma-separated list of columns to exclude from the output (only for HTML renderer) ex.: -col1,col2
  • file_name - custom file name for the output file*

*file:

  • Default encoding for all files is UTF-8.
  • Encoding can be overridden by adding encoding after a comma in the query string.
  • Example ANSI encoding: /api/srs/123/test.hbs.txt?file_name=test.txt,ansi
  • Custom file name /api/srs/123/test.hbs.txt?file_name=test.txt