Using Zoho remote API to edit office documents in a Django app
An introduction to Zoho.com APIs, CloudSQL, and sample usage of Remote API to edit documents, slides and sheets on a Django powered website. Full source code of the app included.
Zoho.com is a set of web applications - for communication, collaboration, and documents management (documents, sheets, presentations/slides). There are two APIs available for those apps - Data API used on documents and data stored on Zoho apps, that you use, and Remote API that is used on documents stored on your server. The Data API allows more collaboration, and getting precise sets of data (look at CloudSQL). Remote API allows you to use Zoho editors (Writer, Sheet, Show and others) to edit documents (doc, odt, ppt, odp, xls, ods and many more) on your site. More on api.wiki.zoho.com.
Document editing in a Django App
Sheet and slidesRemote API for Zoho Sheet and Zoho Show is more simple. You can use the editor, but the API won't return the JS code. Instead you will get the editor URL in response headers (Location header). To handle that we have to use pycurl slightly different: Instead of getting the response body we now collect response headers, and if there is "Location" header - we extract the URL and use it to show the editor in an iframe:
Zoho Data API and CloudSQL
The Data API won't let us use the editors on our websites, but it allows us to manipulate files and data stored in the zoho apps we use. The most interesting for app-making is the data stored in Zoho Reports (and Sheets). Using CloudSQL we can query data saved in sheets and process it in out apps (make reports, whatever). You can check Get Started with Zoho CloudSQL in 4 easy steps.Here is an example CloudSQL usage with the Python library from Zoho, that maps most of the SQL to objects: You can get the database and table name from the Reports app: On those screen shots the database is "test", and table "testowy" (is a sheet). As for the Python API - you will find docs in the package. exportData is used to get data from Reports in a selected format. It takes - "link" to the table, the data format, file object and optional - filter parameters. You can also use plain API calling URL with urllib2: Executing a SQL Query. Database is a "database" of reports in Zoho Reports. Table is a sheet in the Reports app (a database table rendered as a sheet). column is a sheet column (and the named as you set the column name in the sheet).