pip install requests
pip install sphinx
pip install .Zoho Analytics REST API supports OAuth 2.0 protocol to authorize and authenticate API calls. Follow the steps listed here to use OAuth 2.0 protocol in Zoho Analytics APIs.
- Step 1: Registering New Client
- Step 2: Generating Code
- Step 3: Generating Refresh Token
- Step 4: Generating Access Token
The scope for full access
ZohoAnalytics.fullaccess.all
from connector_analytics.analyticsV2 import zohoConnectV2class Config:
SERVERAUTH = ''
SERVERURL = ''
LOGINEMAILID = ''
CLIENTID = ''
CLIENTSECRET = ''
REFRESHTOKEN = ''
| Data Centre | ZohoAnalytics_Server_URI | ZohoAccounts_Server_URI |
|---|---|---|
| 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 |
Example for Config.py
class Config:
SERVERAUTH = 'https://accounts.zoho.com'
SERVERURL = 'https://analyticsapi.zoho.com/api/user@domain.com/table'
LOGINEMAILID = 'user@domain.com'
CLIENTID = '******'
CLIENTSECRET = '******'
REFRESHTOKEN = '******'
objZoho = zohoConnectV2(srvUrl=Config.SERVERAUTH,
tokenToRefresh=Config.REFRESHTOKEN,
clientId=Config.CLIENTID,
clientSecret=Config.CLIENTSECRET)Tip : Where are workspace and view_id ? check the url of your table https://analytics.zoho.com/workspace/<workspace_id>/view/<view_id> orgid is the organization id check you setting in zoho
columns = {
'Id':'1',
'Name':'Armando Aguilar',
'Cell':'52-55555-555',
'Country':'CDMEX'}
url = 'https://analyticsapi.zoho.com'
objZoho.addRow(srvUrl=url,
workspace='51001910',
view_id='5100191000',
orgid='99999',
columns=columns)Tip : Where are workspace and view_id ? check the url of your table https://analytics.zoho.com/workspace/<workspace_id>/view/<view_id> orgid is the organization id check you setting in zoho
criteria = '\"users\".\"Id\"=\'1\''
columns = {
'Cell':'52-6666-666',
'Country':'California'
}
update = objZoho.updateRow(srvUrl='https://analyticsapi.zoho.com',
workspace='3100191',
view_id='310019',
orgid='5987',
criteria=criteria,
columns=columns)Tip : Where are workspace and view_id ? check the url of your table https://analytics.zoho.com/workspace/<workspace_id>/view/<view_id> orgid is the organization id check you setting in zoho
criteria = '"users"."Id"=4'
delete = objZoho2.deleteRow(srvUrl='https://analyticsapi.zoho.com',
workspace='3100191,
view_id='310019',
orgid='5987',
criteria=criteria,
deleteAllRows='true')
Use a simple cvs or format in a string to insert rows in the table of zoho in this example we used this files called users.cvs.
- APPEND Appends the data into the table.
- TRUNCATEADD - Deletes all exisiting rows in the table and adds the imported data as new entry.
- UPDATEADD Updates the row if the mentioned column values are matched, else a new entry will be added.
| Id | Name | Country |
|---|---|---|
| 1 | User 1 | MX |
| 2 | User 2 | CAD |
| 3 | User 3 | UK |
| 4 | User 4 | USA |
with open('users.csv', 'r') as f:
data = f.read()
autoIdentify = "true"
onError = "ABORT"APPEND Appends the data into the table.
Tip: ImportRows can be data of real csv file or string with the format cvs.
objZoho.importRows(srvUrl='https://analyticsapi.zoho.com',
workspace='4100191',
view_id='4100191000',
data=data,
importType='APPEND',
orgid='897665555',
autoIdentify='true',
delimiter='1')Tip : matchingColumns is the criterian for make the MATCHING, it can be one or more values separate by coma.
columns = {'id','Name','Country'}
objZoho.importRows(srvUrl='https://analyticsapi.zoho.com',
workspace='4100191',
view_id='4100191000',
data=data,
importType='UPDATEADD',
orgid='897665555',
autoIdentify='true',
matchingColumns=columns)objZoho.importRows(srvUrl='https://analyticsapi.zoho.com',
workspace='4100191',
view_id='4100191000',
data=data,
importType='TRUNCATEADD',
orgid='897665555',
autoIdentify='true')Tip : When you write the sentences SQL you need add %20 in the blank spaces.
sql_query = "SELECT%20id,name,country%20FROM%20dusers%20WHERE%20country='MX'"
data = objZoho.zohoQuery(srvUrl='https://analyticsapi.zoho.com',
orgid='000000',
workspace='workspace name',
table_name='users',
email='user@domain.com',
sql_query=sql_query)| BTC | LTC |
|---|---|
![]() |
![]() |
| 1JDA4DEkVnB9rvLgLD5Xe9jfU2pJtnCZiG | LhBrMcs7i3mD2wjiUv3KGtx9eEQeyBE4Dg |

