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

  • pscope optional query parameter - limits execution to comma-separated command names
  • ptoken optional query parameter - authorizes request with token. See authentication
  • 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:

Basic types

  • api - optimized JSON format (array of tables) for internal use
  • [name].json - JSON object, simplified format
  • [name].lower.json - JSON object, simplified format with lowercase property names
  • .html - all columns except those with ex="false"; empty commands and commands with types hidden or server are not exported
  • .xlsx - only columns with ex="false"; empty datasets and types hidden or server are not exported
  • .txt - raw data
  • .md - raw data with formatted tables

Handlebars templates

This format uses Handlebars templates. A template is required in /template as file {renderer}.hbs.

  • .hbs.html - html
  • .hbs.pdf - pdf
  • .hbs.csv - csv
  • .hbs.txt - txt
  • .hbs.xml - xml
  • .hbs.epp - epp
  • .hbs.svg - svg

Extra parameters

file_name

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

Pixel-Perfect PDF/HTML

This format uses Fast Report templates. A template is required in /template as file {renderer}.frx.

  • .frx.html - HTML; requires an .frx template in the /template directory
  • .frx.pdf - PDF; requires an .frx template in the /template directory
  • .frx - report template with data (srs_Administrator)