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
oauthscope: ZohoAnalytics.modeling.create
QUERY PARAMETERS
| Description |
---|---|
CONFIG* | JSONObject Config parameter specifications are available in the below section. |
FIELDS FOR CONFIG JSON
Key | Description |
---|---|
baseTableName* | String Name of the base table used to create report. |
title* | String Name of the report. |
description | String Description of the report. |
reportType* | String Accepted Values:
|
chartType | String Specifies the type of chart to be created. Accepted Values: Area Charts:
Bar Charts:
Bubble Charts:
Combo Charts:
Funnel and Pyramid Charts:
Line Charts:
Map Charts:
Pie and Ring Charts:
Scatter Charts:
Web Charts:
Heat Maps:
Other Charts:
|
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 Accepted Values:
|
mergeAxisInfo | String Sample: {"axisIndex":[2,3],"labelName":"Merge_axis"} |
AXIS COLUMN STRUCTURE ATTRIBUTE
Key | Description | ||||||||
type* | String Accepted Values:
| ||||||||
columnName* | String Name of the column used in the report. | ||||||||
operation* | String Accepted Values:
|
Key | Description | ||||||||||||||||||||||||||||||||||||||||||||||||
tableName* | String Name of the table used to create report. | ||||||||||||||||||||||||||||||||||||||||||||||||
columnName* | String Specifies the name of the column used in the filter. | ||||||||||||||||||||||||||||||||||||||||||||||||
operation* | String Accepted Values:
| ||||||||||||||||||||||||||||||||||||||||||||||||
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
| ||||||||||||||||||||||||||||||||||||||||||||||||
exclude* | String Indicates whether to include or exclude values for this filter. Accepted Values:
|
USER FILTER STRUCTURE ATTRIBUTE
Key | Description | ||||||||
tableName* | String Name of the table used to create report. | ||||||||
columnName* | String Specifies the name of the column used in the filter. | ||||||||
operation* | String Accepted Values:
|
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"
}
}