Skip to main content

Zoho Analytics has been recognized in the 2024 Gartner® Magic Quadrant™ for ABI PlatformsRead more

Create Report

The Chart Creation API in Zoho Analytics allows users to effortlessly generate different types of data visualizations like charts, pivot, and summary tables. This API simplifies the process of creating customized views, making it easy to analyze and present data.

REQUEST URI

https://<ZohoAnalytics_Server_URI>/restapi/v2/workspaces/<workspace-id>/reports

Post

oauthscopeZohoAnalytics.modeling.create

QUERY PARAMETERS

 

Parameter Name
Description
CONFIG*JSONObject

Config parameter specifications are available in the below section.

FIELDS FOR CONFIG JSON

KeyDescription
baseTableName*String

Name of the base table used to create report.
title*String

Name of the report.
descriptionString

Description of the report.
reportType*

String

Specifies the type of report to be created.

Accepted Values:

  • chart
  • pivot
  • summary
chartType

String

Specifies the type of chart to be created.

Accepted Values:

Area Charts:

  • area
  • area with points
  • area without points
  • smooth area
  • smooth area with points
  • smooth area without points
  • stacked area
  • stacked area with points
  • stacked smooth area
  • stacked smooth area with points
  • stacked smooth area without points

Bar Charts:

  • bar
  • horizontal bar
  • stacked bar
  • horizontal stacked bar

Bubble Charts:

  • bubble
  • packed bubble

Combo Charts:

  • combo
  • combo bar with smooth line

Funnel and Pyramid Charts:

  • funnel
  • pyramid

Line Charts:

  • line
  • line with points
  • line without points
  • smooth line
  • smooth line with points
  • smooth line without points
  • step

Map Charts:

  • map area
  • map bubble
  • map filled
  • map pie
  • map pie bubble
  • map bubble pie
  • map scatter
  • geo heat map

Pie and Ring Charts:

  • pie
  • ring
  • semi pie
  • semi ring

Scatter Charts:

  • scatter

Web Charts:

  • web
  • web with fill
  • web without fill

Heat Maps:

  • heat map

Other Charts:

  • butterfly
  • table chart
axisColumns*JSONArray

Detailed information about the columns like type, column name, and functions applied over these columns in report. Check the table Axis Column Structure for more details.
filters

JSONArray

Detailed information about the filters like table name, column name, function applied, and filter type. Check the table Filter Structure for more details.

userFilters

JSONArray

Detailed information about the user filters like table name, column name, function applied, and filter type. Check the table User Filter Structure for more details.

isAxisMerge

String

Gives information about merge axis.

Accepted Values:

  • true
  • false
mergeAxisInfo

String

Contain details about the Y-axis that need to be merged and the label name of the merged axis.

Sample: {"axisIndex":[2,3],"labelName":"Merge_axis"}

 

AXIS COLUMN STRUCTURE ATTRIBUTE

KeyDescription
type*

String

Defines the type of the specified column used in the report.

Accepted Values:

Report TypeAccepted Values
chart
  • xAxis
  • yAxis
  • textAxis
  • colorAxis
  • toolTip
pivot
  • row
  • column
  • data
summary
  • groupBy
  • summarize
columnName*String

Name of the column used in the report.
operation*

String

Specifies the function applied to the specified column used in the report. The accepted functions differ based on the data type of the column.

Accepted Values:

Data TypeAccepted Values
Dateyear, quarterYear, monthYear, weekYear, fullDate, dateTime, range, quarter, month, week, weekDay, day, hour, count, distinctCount
Numericmeasure, dimension, range, actual, sum, min, max, average, stdDev, median, mode, count, variance, distinctCount, actual
Stringactual, count, distinctCount

 

FILTER STRUCTURE ATTRIBUTE

KeyDescription
tableName*String

Name of the table used to create report.
columnName*

String

Specifies the name of the column used in the filter.

operation*

String

Specifies the function applied to the specified column used in the filter. The accepted functions differ based on the data type of the column.

Accepted Values:

Data TypeAccepted Values
Dateactual, seasonal, relative 
Numericmeasure, dimension, range, actual, sum, min, max, average, stdDev, median, mode, count, variance, distinctCount
Stringactual, count, distinctCount
filterType*

String

Specifies the type of filter to be used in the report.

Accepted values: 

individualValues, range, ranking, rankingPct, dateRange, year, quarterYear, monthYear, weekYear, quarter, month, week, weekDay, day, hour, dateTime

Accepted values based on data type

Numeric: individualValues, range, ranking, rankingPct

Date: year, quarterYear, monthYear, weekYear, fullDate, dateTime, range, quarter, month, week, weekDay, day, hour, count, distinctCount

values*

JSONArray

Specifies the array of values used in the specified filter.

Sample: ["1000 to 2000", "3000 to 4000"]

Accepted Values: Array of Values

Filter TypeExamples
ranking"Top 2" , "Top 5"
range"100000 and below","200000 to 300000","500000 and above"
individualValues"20.97","700.59"
Date - Actual
year"2012","2013"
monthYear"Aug 2012","Jan 2013"
weekYear"W03 2012","W02 2012"
quarterYear"Q1 2012","Q2 2013"
actual"10 Mar 2012","11 Mar 2012"
dateTime"10 Mar 2012 10:00:00","11 Mar 2012 11:00:00"
dateRange"from 10 Dec 2013 00:00:00","10 Mar 2012 00:00:00 to 10 Dec 2012 00:00:00","to 11 Mar 2013 00:00:00"
Date - Seasonal
quarter "Q1","Q2"
month "Jan","Feb"
week"Week 2","Week 3","Week 4"
weekDay "Sun","Mon"
day"01","02"
hour"10","11","13"
Date - Relative
year"This Year","Next Year","Last Year","Last 2 Years"
month"This Month","Next Month","Last Month","Last 2 Months"
hour"This Hour","Next Hour","Last 1 Hour","Last 2 Hour"
week "This Week","Next Week","Last Week","Last 2 Weeks"
exclude*

String

Indicates whether to include or exclude values for this filter.

Accepted Values: 

  • true
  • false

 

USER FILTER STRUCTURE ATTRIBUTE

KeyDescription
tableName*String

Name of the table used to create report.
columnName*

String

Specifies the name of the column used in the filter.

operation*

String

Specifies the function applied to the specified column used in the filter. The accepted functions differ based on the data type of the column.

Accepted Values:

Data TypeAccepted Values
Dateactual, seasonal, relative 
Numericmeasure, dimension, range, actual, sum, min, max, average, stdDev, median, mode, count, variance, distinctCount
Stringactual, count, distinctCount

POSSIBLE ERROR CODES

7138, 8092, 8144, 7301, 8021, 8145, 8050, 7725, 8052, 8053, 8059, 8056, 8093, 8094, 8095, 8096, 8097, 8099, 8100, 8101, 8054, 8055

 

Sample Request:

Copiedcurl https://analyticsapi.zoho.com/restapi/v2/workspaces/<workspace-id>/reports --data-urlencode 'CONFIG={"baseTableName":"Sales","title":"A1","description":"desc","reportType": "chart","axisColumns":[{"type":"xAxis","columnName":"Date","operation":"year"},{"type":"yAxis","columnName":"Sales","operation":"sum"}]}' 
-X 'POST' 
-H 'ZANALYTICS-ORGID: <org-id>' 
-H 'Authorization: Zoho-oauthtoken <access_token>'
Copiedusing System;
using System.Collections.Generic;
using ZohoAnalytics;
using System.Text.Json;

namespace ZohoAnalyticsTest
{
    class Program
    {
        long orgId = 55522777;
        long workspaceId = 35130000001055707;

        public void CreateReport(IAnalyticsClient ac)
        {
            Dictionary<string, object> config = new Dictionary<string, object>();
            config.Add("baseTableName", "Sales");
            config.Add("title", "New Chart");
            config.Add("reportType", "chart");

            List<Dictionary<string, object>> axisColumns = new List<Dictionary<string, object>>();

            Dictionary<string, object> xAxis = new Dictionary<string, object>();
            xAxis.Add("type", "xAxis");
            xAxis.Add("columnName", "Date");
            xAxis.Add("operation", "year");

            Dictionary<string, object> yAxis = new Dictionary<string, object>();
            yAxis.Add("type", "yAxis");
            yAxis.Add("columnName", "Sales");
            yAxis.Add("operation", "sum");

            axisColumns.Add(xAxis);
            axisColumns.Add(yAxis);
            config.Add("axisColumns", axisColumns);

            IWorkspaceAPI ws = ac.GetWorkspaceInstance(orgId, workspaceId);
            long viewId = ws.CreateReport(config);
            Console.WriteLine(viewId);
        }

        static void Main(string[] args)
        {
            string clientId = "1000.xxxxxxx";
            string clientSecret = "xxxxxxx";
            string refreshToken = "1000.xxxxxxx.xxxxxxx";

            try
            {
                IAnalyticsClient ac = new AnalyticsClient(clientId, clientSecret, refreshToken);
                Program obj = new Program();
                obj.CreateReport(ac);
            }
            catch (ServerException ex)
            {
                Console.WriteLine("Server exception - " + ex.GetErrorMessage());
            }
            catch (Exception ex)
            {
                Console.WriteLine("Other exception - " + ex.Message);
            }
        }
    }
}
Copiedpackage main

import (
    "fmt"
    ZAnalytics "zoho/pkg/analyticsclient"
)

var(
    clientId = "1000.xxxxxxx"
    clientSecret = "xxxxxxx"
    refreshToken = "1000.xxxxxxx.xxxxxxx"

    orgId = "55522777"
    workspaceId = "35130000001055707"
)

func CreateReport(ac ZAnalytics.Client) {

    basetablename := "Sales"

    xaxis := map[string]interface{}{
        "type": "xAxis",
        "columnName": "Date",
        "operation": "year",
    }

    yaxis := map[string]interface{}{
        "type": "yAxis",
        "columnName": "Sales",
        "operation": "sum",
    }

    axiscolumns := []map[string]interface{}{xaxis, yaxis}

    config := map[string]interface{}{
        "baseTableName": basetablename,
        "title":    "New Chart",
        "reportType": "chart",
        "axisColumns": axiscolumns,
    }

    workspace := ZAnalytics.GetWorkspaceInstance(&ac, orgId, workspaceId)
    viewid, exception := workspace.CreateReport(config)
    if(exception != nil){
        fmt.Println(exception.ErrorMessage)
    }else{
        fmt.Println(viewid)
    }
}

func main() {

    ac := ZAnalytics.GetAnalyticsClient(clientId, clientSecret, refreshToken)
    CreateReport(ac)

}
Copiedimport com.zoho.analytics.client.*;
import org.json.*;

public class Test {

    private long orgId = 55522777l;
    private long workspaceId = 35130000001055707l;

    public static void main(String args[]){

        String clientId = "1000.xxxxxxx";
        String clientSecret = "xxxxxxx";
        String refreshToken = "1000.xxxxxxx.xxxxxxx";

        Test tObj = new Test();
        AnalyticsClient ac = new AnalyticsClient(clientId, clientSecret, refreshToken);

        try {
            tObj.createReport(ac);
        }
        catch (ServerException ex) {
            System.out.println("Server exception - ErrorCode : " + ex.getErrorCode() + ", ErrorMessage : "  + ex.getErrorMessage());
        }
        catch (ParseException ex) {
            System.out.println("Parser exception - ErrorMessage : "  + ex.getResponseMessage());
        }
        catch (Exception ex) {
            System.out.println("Other exception - ");
            ex.printStackTrace();
        }
    }

    public void createReport(AnalyticsClient ac) throws Exception {

        String baseTableName = "Sales";

        JSONObject xAxis = new JSONObject();
        xAxis.put("type", "xAxis");
        xAxis.put("columnName", "Date");
        xAxis.put("operation", "year");

        JSONObject yAxis = new JSONObject();
        yAxis.put("type", "yAxis");
        yAxis.put("columnName", "Sales");
        yAxis.put("operation", "sum");

        JSONArray axisColumns = new JSONArray();
        axisColumns.put(xAxis);
        axisColumns.put(yAxis);

        JSONObject config = new JSONObject();
        config.put("baseTableName", baseTableName);
        config.put("title", "New Chart");
        config.put("reportType", "chart");
        config.put("axisColumns", axisColumns);


        WorkspaceAPI workspace = ac.getWorkspaceInstance(orgId, workspaceId);
        long viewId = workspace.createReport(config);
        System.out.println(viewId);
    }
}
Copied<?php

    require 'AnalyticsClient.php';

    class Test
    {
        public $ac = NULL;
        public $client_id = "1000.xxxxxxx";
        public $client_secret = "xxxxxxx";
        public $refresh_token = "1000.xxxxxxx.xxxxxxx";

        public $org_id = "55522777";
        public $workspace_id = "35130000001055707";

        function __construct() {
            $this->ac =  new AnalyticsClient($this->client_id, $this->client_secret, $this->refresh_token);
        }

        function createReport() {
            $base_table_name = "Sales";

            $x_axis = [
                "type" => "xAxis",
                "columnName" => "Date",
                "operation" => "year"
            ];

            $y_axis = [
                "type" => "yAxis",
                "columnName" => "Sales",
                "operation" => "sum"
            ];

            $axis_columns = [$x_axis, $y_axis];

            $config = [
                "baseTableName" => $base_table_name,
                "title" => "New Chart",
                "reportType" => "chart",
                "axisColumns" => $axis_columns
            ];

            $workspace = $this->ac->getWorkspaceInstance($this->org_id, $this->workspace_id);
            $view_id = $workspace->createReport($config);
            print_r($view_id);
        }
    }

    $test_obj = new Test();

    try {
        $test_obj->createReport();
    }
    catch(ServerException $se) {
        echo "Server exception : " . $se->getErrorMessage() . "\n";
    }
    catch(IOException $ioe) {
        echo "IO exception : " . $ioe->getErrorMessage() . "\n";
    }
    catch(ParseException $pe) {
        echo "Parser exception : " . $pe->getErrorMessage() . "\n";
    }
    catch(Exception $e) {
        echo "Exception : " . $e->getErrorMessage() . "\n";
    }
?>
Copiedfrom __future__ import with_statement
from AnalyticsClient import AnalyticsClient
import sys
import json

class Config:

    CLIENTID = "1000.xxxxxxx";
    CLIENTSECRET = "xxxxxxx";
    REFRESHTOKEN = "1000.xxxxxxx.xxxxxxx";

    ORGID = "55522777";
    WORKSPACEID = "35130000001055707";

class sample:

    ac = AnalyticsClient(Config.CLIENTID, Config.CLIENTSECRET, Config.REFRESHTOKEN)

    def create_report(self, ac):
        base_table_name = "Sales"

        xaxis = {
            "type": "xAxis",
            "columnName": "Date",
            "operation": "year"
        }

        yaxis = {
            "type": "yAxis",
            "columnName": "Sales",
            "operation": "sum"
        }

        axis_columns = [xaxis, yaxis]

        config = {
            "baseTableName": base_table_name,
            "title": "New Chart",
            "reportType": "chart",
            "axisColumns": axis_columns
        }

        workspace = ac.get_workspace_instance(Config.ORGID, Config.WORKSPACEID)
        view_id = workspace.create_report(config)
        print(view_id)

try:
    obj = sample()
    obj.create_report(obj.ac);

except Exception as e:
    print(str(e))
Copiedvar analyticsClient = require('./AnalyticsClient');

const clientId = '1000.xxxxxxx';
const clientSecret = 'xxxxxxx';
const refreshToken = '1000.xxxxxxx.xxxxxxx';
const orgId = '55522777';
const workspaceId = '35130000001055707';

const ac = new analyticsClient(clientId, clientSecret, refreshToken);

const baseTableName = "Sales";

const xaxis = {
    type: "xAxis",
    columnName: "Date",
    operation: "year"
};

const yaxis = {
    type: "yAxis",
    columnName: "Sales",
    operation: "sum"
};

const axisColumns = [xaxis, yaxis];

const config = {
    baseTableName: baseTableName,
    title: "New Chart",
    reportType: "chart",
    axisColumns: axisColumns
};

const workspace = ac.getWorkspaceInstance(orgId, workspaceId);
workspace.createReport(config).then((response) => {
    console.log(response);

}).catch((error) => {
    console.log('errorCode : '+error.errorCode);
    console.log('errorMessage : '+error.errorMessage);
});
CopiedorgId = "55522777";
workspaceId = "35130000001055707";

headersMap = Map();
headersMap.put("ZANALYTICS-ORGID", orgId);

baseTableName = "Sales";

xAxis = Map();
xAxis.put("type", "xAxis");
xAxis.put("columnName", "Date");
xAxis.put("operation", "year");

yAxis = Map();
yAxis.put("type", "yAxis");
yAxis.put("columnName", "Sales");
yAxis.put("operation", "sum");

axisColumns = List();
axisColumns.add(xAxis);
axisColumns.add(yAxis);

config = Map();
config.put("baseTableName", baseTableName);
config.put("title", "New Chart");
config.put("reportType", "chart");
config.put("axisColumns", axisColumns);

paramsMap = Map();
paramsMap.put("CONFIG", config.toString());

response = invokeurl
[
    url :"https://analyticsapi.zoho.com/restapi/v2/workspaces/" + workspaceId + "/reports"
    type :POST
    parameters: paramsMap
    headers: headersMap
    connection:"analytics_oauth_connection"
];

info response;

Download client SDKs : C# | GO | JAVA | PHP | PYTHON | NodeJS

Sample value for CONFIG parameter:

Copied{
    "baseTableName": "Sales",
    "title": "A1",
    "description": "desc",
    "reportType": "chart",
    "axisColumns": [
        {
            "type": "xAxis",
            "columnName": "Date",
            "operation": "year"
        },
        {
            "type": "yAxis",
            "columnName": "Sales",
            "operation": "sum"
        }
    ]
}

Sample Response:

CopiedHTTP/1.1 200 OK
Content-Type:application/json;charset=UTF-8

{
    "status": "success",
    "summary": "Create report",
    "data": {
        "viewId": "35130000006450002"
    }
}
 
 
Thanks for your interest. We shall get back to you shortly.