Prerequisites
Before delving into the Zoho Analytics API, let's take a moment to address the essential prerequisites that will ensure you have the necessary background knowledge to follow along.
- Users should have a valid Zoho login email address to use the API. If you do not have one, please Sign up into Zoho Analytics and create a login.
- It is mandatory to use HTTPS in all API requests instead of HTTP request. HTTP is not supported
- Choose your <ZohoAnalytics_Server_URI> and use the same in API request URI.
- An access token is mandatory to authorize the user. Refer this link to know how to generate an access token.
Scopes
Zoho Analytics APIs use selected scopes, which control the type of API's that the client application (or) end user can access. Tokens are usually created with specific scopes to restrict it from acceessing other API's. For example, You can generate a scope to create a view (or) to view metadata and so on. Scopes contain three parameters — service name, scope name, and operation type.
Scope | Description |
---|---|
data | To access data related APIs Availabe Scopes: ZohoAnalytics.data.read, ZohoAnalytics.data.delete, ZohoAnalytics.data.update, ZohoAnalytics.data.create, ZohoAnalytics.data.all |
modeling | To access modeling related APIs Availabe Scopes: ZohoAnalytics.modeling.delete, ZohoAnalytics.modeling.update, ZohoAnalytics.modeling.create, ZohoAnalytics.modeling.all |
metadata | To access metadata related APIs Availabe Scopes: ZohoAnalytics.metadata.read, ZohoAnalytics.metadata.all |
share | To access sharing related APIs Availabe Scopes: ZohoAnalytics.share.delete, ZohoAnalytics.share.read, ZohoAnalytics.share.create, ZohoAnalytics.share.all |
embed | To access embed related APIs Availabe Scopes: ZohoAnalytics.embed.read, ZohoAnalytics.embed.all |
usermanagement | To access usermanagement related APIs Availabe Scopes: ZohoAnalytics.usermanagement.read, ZohoAnalytics.usermanagement.delete, ZohoAnalytics.usermanagement.update, ZohoAnalytics.usermanagement.create, ZohoAnalytics.usermanagement.all |
fullaccess | To access all ZohoAnalytics APIs Availabe Scope: ZohoAnalytics.fullaccess.all |
Applying Filter Criteria
Zoho Analytics API allows you to apply filter criteria while you execute the various actions. On applying a criteria, the action will be performed only on the data that matches the given filter criteria.
You can apply criteria as part of the following API actions:
- Update
- Delete
- Export
- Share
- Get View Url
- Get Embed Url
- Create Private URL
The filter criteria has to be passed as a JSON attribute named “criteria“ in the API request.
FORMAT
The filter criteria that is passed as part of the request, should follow the same format as that of the SQL SELECT WHERE clause.
The generalized format of a simple criteria is given below:
(<columnname/SQL expression/SQL function calls> <relational operator> <value/column name/SQL expression/SQL function calls>)
On using criteria for views which involves multiple tables having the same column name, the criteria should append with the table name to avoid name mismatch.
<tablename>.<columnname> <relational operator> <value/column name/SQL expression/SQL function calls>
DESCRIPTION
The criteria follows the SQL SELECT WHERE condition like format. You could also use SQL in-built functions as part of the criteria. These built-in functions should be the functions supported by any of Oracle, MS SQL Server, MySQL, DB2, Sybase, ANSI SQL, Informix and PostgreSQL databases.
Name | Description |
---|---|
column name | Refers to the column name of your table or query table on which you are applying a criteria. |
SQL Expression | You could provide any valid SQL Expression. The above expression subtracts the value in the “Cost” column from the value in the “Sales” column. You could use any of the Arithmetic operators supported in an Supported Arithmetic Operators: +, -, *, / |
SQL Function call | Oracle, MS SQL Server, MySQL, DB2, Sybase, ANSI SQL, Informix and PostgreSQL databases Eg.: year(date_column) = 2008 . Note: All supported in-built function from different databases will be documented soon. |
relational operator | This could be any of the relational operators supported in an
|
value | Refers to the exact value to match. Eg.: "Department" = 'Finance' here 'Finance' is a literal value to match. |
NOTES FOR CRITERIA FORMATION:
- You can combine any number of criteria that is defined in the above specified format using logical operators like AND and OR to form complex criteria, the same way as in SQL SELECT WHERE clause. Always use Braces ’()’ to group the criteria for ordering.
- Enclose string literals (ie values) in single quotes.
- Enclose table name and column name in double quotes.
Eg.: "table_1"."number_column">"table_2"."number_column"
Eg.: "plaintext_column"='country'
Eg.: number_column=75 is valid - Date Format should be either
yyyy-mm-dd
oryyyy-mm-dd hh:mm:ss
Eg.: "date_column"='2007-01-31 00:00:00' - Currency symbols (or) percent symbol can’t be used in criteria
Eg.: currency_column=75.66 is valid
Eg.: percent_column=100 is valid
currency_column=75.66$ (or) percent_column=100% is not valid
Refer to the SQL SELECT WHERE clause documentation of any database that we support, to know more on how to construct the filter criteria.
View this link for more details about how to construct a custom date format.
Example
Copied(( "Sales"."Region"='East' and "Sales"<1000) or ("Sales"."Region"='West'
and "Sales"<2000))
Sample
CopiedA sample delete request that deletes all the rows that match the criteria
"Sales"."Region"='East' is given below.
URL
Copiedhttps://analyticsapi.zoho.com/restapi/v2/workspaces/1767025050053160012/views/1769024500004160002/rows?CONFIG={"criteria":"\"Sales\".\"Region\"='East'"}