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.analytics import zohoConnect
class 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 = zohoConnect(srvUrl=Config.SERVERAUTH,
tokenToRefresh=Config.REFRESHTOKEN,
clientId=Config.CLIENTID,
clientSecret=Config.CLIENTSECRET)
payload = {
'Id':'1',
'Name':'Armando Aguilar',
'Cell':'52-55555-555',
'Country':'CDMEX'}
objZoho.addRow(tableURL=Config.SERVERURL,columnsValues=payload)
conditional = 'Id=1'
payload = {
'Name':'Armando Aguilar L.',
'Cell':'52-895578-6789',
'Country':'UK'}
update = objZoho.updateRow(tableURL=Config.SERVERURL,
updateInfo=payload,
conditionalInfo=conditional)
conditional = 'Id=1'
delete = objZoho.deleteRow(tableURL=Config.SERVERURL,
conditionalInfo=conditional)
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(tableURL= Config.SERVERURL,
importType='APPEND',
importData=data, Identify=False)
Updates the row if the mentioned column values are matched, else a new entry will be added.
Tip : Columns is the criterian for make the MATCHING, it can be one or more values separate by coma.
objZoho.ImportRows(tableURL=Config.SERVERURL,
importType='UPDATEADD',
importData=data,
Identify=False,
Columns='Id')
Deletes all exisiting rows in the table and adds the imported data as new entry.
objZoho.ImportRows(tableURL=Config.SERVERURL,
importType='TRUNCATEADD',
importData=data)
The criteria field is the way to make match in the table.
conditional = 'Id=1'
objZoho.readData(tableURL=Config.SERVERURL,criteria=conditional)
Literal SQL Query can be used as criteria.Export using joining tables and specific columns can be done using.
sql_query = 'SELECT \"Id\",\"Name\" FROM users Where \"Id\" = \'1\''
objZoho.readQuery(tableURL=Config.SERVERURL,queryStr=sql_query)
BTC | LTC |
---|---|
1JDA4DEkVnB9rvLgLD5Xe9jfU2pJtnCZiG | LhBrMcs7i3mD2wjiUv3KGtx9eEQeyBE4Dg |