API Specification
Zoho Analytics API uses HTTP as the underlying transport protocol. It is based on REST principles. The following are the basic points of how the REST APIs are structured:
- Every table/report/dashboard in a Zoho Analytics workspace can be uniquely identified using a URL.
- The operation to be performed on the table/report/dashboard can be specified using the parameters in the URL.
- The additional payload required to perform the operation should also be specified as parameters in the URL.
- Every request has a response whose format can be controlled using parameters in the request URL.
It is important to understand the API specification clearly before referring to the actual API methods.
Server URI
The following server URI are available for Zoho Analytics. Choose the server URI based on your data centre.
Data Centre | ZohoAnalytics_Server_URI | ZohoAccounts_Server_URI | DeveloperConsole |
---|---|---|---|
US (United States) | analyticsapi.zoho.com | accounts.zoho.com | |
EU (Europe) | analyticsapi.zoho.eu | accounts.zoho.eu | |
IN (India) | analyticsapi.zoho.in | accounts.zoho.in | |
AU (Australia) | analyticsapi.zoho.com.au | accounts.zoho.com.au | |
CN (China) | analyticsapi.zoho.com.cn | accounts.zoho.com.cn | |
JP (Japan) | analyticsapi.zoho.jp | accounts.zoho.jp |
Request Format
All API requests should be placed as HTTPS requests. A request consists of the following components:
- URI (Universal Resource Identifier. Also commonly known as URL)
- Config to be passed in Query String
- Authorization Using OAuth 2.0
- Organization ID ( can be obtained using Get Organizations API )
URI
The URI of each resource can be obtained by accessing the API Root Endpoint.
Sample: https://<ZohoAnalytics_Server_URI>/restapi/v2/workspaces
CONFIG to be passed in Query String
The following snippet shows the config that should be passed as query string with the URI defined above.
https://<end_point>?CONFIG={"workspaceName":"<workspace-name>"}
Authorization using OAUTH 2.0
Access token have to be passed in the header for authorization purpose in the format given below.
Authorization: Zoho-oauthtoken <access_token>
Organization ID
Zoho Analytics Organization
For every organization in Zoho Analytics an unique ID (Organization ID) is present. The header “ZANALYTICS-ORGID“ with the 'Organization ID' should be sent with the API request to identify the organization.
ZANALYTICS-ORGID: <organization_id>
Using Get Organizations API the list of all accessible organizations can be obtained.
Sample Request
Copiedcurl https://analyticsapi.zoho.com/restapi/v2/workspaces
--data-urlencode 'CONFIG={
"workspaceName":"<workspace-name>"
}'
-X 'POST'
-H 'ZANALYTICS-ORGID: <org-id>'
-H 'Authorization: Zoho-oauthtoken <access_token>'
Response Format
Zoho Analytics supports JSON response format for APIs. CSV, JSON, XML, PDF, HTML and Image response formats are supported only for Export API.
Formats such as CSV, PDF can be specified only for EXPORT API. These formats don’t have any generic parseable header/footer. See this link for more details about these formats.
Sample Response
CopiedHTTP/1.1 200 OK
Content-Type:application/json;charset=UTF-8
{
"status": "success",
"summary": "Create workspace",
"data": {
"workspaceId": "1767024000003145002"
}
}
Error handling
API execution could result in Error conditions. In such cases, follow the below steps to identify an error condition and handle the same:
- Check the HTTP response code. If it is 4xx or 5xx (eg., 400, 500, 401, etc.,), then it is an error.
- In case of error, the error information would be sent in the response body.
Sample Error
CopiedHTTP/1.1 400 Bad Request
Content-Type:application/json;charset=UTF-8
{
"status": "failure",
"summary": "META_DBNAME_DUPLICATE",
"data": {
"errorCode": 7101,
"errorMessage": "Workspace with the same name exists already. Provide an alternate name"
}
}