Implement Catalyst SDK in AppSail

Catalyst enables you to implement the SDK packages of the supported development environments in your AppSail applications for Catalyst-managed runtimes. This enables you to avail other Catalyst services and components in your app’s functionality. You can implement the development SDKs of various programming environments in your app as specified below.

Note: This is only available for web services built for a supported Catalyst-managed runtime. You will not be able to implement Catalyst SDK for apps deployed as OCI images through custom runtime.

Implement Catalyst Java SDK

You can download the Catalyst Java SDK package from the Developer Tools settings in your Catalyst console and include it in your app’s source code. You can then implement the Catalyst Java SDK in your application’s code and initialize it. Refer Catalyst Java SDK help for details about the various functionalities of the SDK toolkit and sample code snippets.

The steps to implement and initialize the Catalyst SDK for different API versions of Java servlets are demonstrated with sample codes below.

In all cases, Catalyst requires you to implement the AuthHeaderProvider interface from the Catalyst Java SDK package. The implementation defines the getHeader() method that returns the value of the request header. You can then pass an object of the implementation class to the init() method, to initialize the SDK.

Java Servlet API versions <=4

Sample code for Java applications that use Java servlets of API versions lesser than or equal to 4.0 (javax.servlet):

Implementation Class:

copy
package com.zoho.catalyst.appsail.demo.utils;
import javax.servlet.http.HttpServletRequest;
import com.zc.auth.AuthHeaderProvider;
public class AuthProviderImpl implements AuthHeaderProvider {
 HttpServletRequest request;
 public AuthProviderImpl(HttpServletRequest request) {
  this.request = request;
 }
 @Override
 public String getHeaderValue(String key) {
  return request.getHeader(key);
 }
}

Initialization:

copy
AuthProviderImpl authProviderImpl = new AuthProviderImpl(req);
CatalystSDK.init(authProviderImpl)

Java Servlet API versions >=5

Sample code for Java applications that use Java servlets of API versions greater than or equal to 5.0 (jakarta.servlet):

Implementation Class:

copy
import com.zc.auth.AuthHeaderProvider;
import jakarta.servlet.http.HttpServletRequest;
public class AuthProviderImpl implements AuthHeaderProvider {
    private HttpServletRequest request;
    AuthProviderImpl(HttpServletRequest request) {
        this.request = request;
    }
    @Override
    public String getHeaderValue(String s) {
        return request.getHeader(s);
    }
}

Initialization:

copy
CatalystSDK.init(new AuthProviderImpl((HttpServletRequest) servletRequest));

If you are developing a Java application with the Maven build tool, you can include the Catalyst Java SDK as a dependency in the Maven configuration file (pom.xml), instead of downloading and adding the SDK in your source code manually.

To add the Catalyst SDK in a Maven project, simply add the Zoho repository (published in MvnRepository) in the pom.xml file as shown below:

copy
<repositories>
	<repository>
      <id>java-sdk</id>
      <url>https://maven.zohodl.com</url>
    </repository>
  </repositories>

You can then add the Java SDK as a dependency in pom.xml as shown below:

copy
<dependencies>
    <dependency>
      <groupId>com.zoho.catalyst</groupId>
      <artifactId>java-sdk</artifactId>
      <version>1.15.0</version>
    </dependency>
 </dependencies>

Implement Catalyst Node.js SDK

You can install the Catalyst Node.js SDK package by executing the following command in your terminal and including it in your app’s source code:

copy
npm install zcatalyst-sdk-node --save

This will install the latest supported version of the Node.js SDK. You can also install a specific supported version in this way:

copy
npm install zcatalyst-sdk-node@2.1.1 --save

You can then initialize the Node.js SDK in your application’s code as shown in the sample code below. This passes the request object to the initialize() method.

copy
const catalyst = require('zcatalyst-sdk-node')
const express = require('express')
const app = express()
app.get((req, res) => {
let catalystApp = catalyst.initialize(req);
//Your code goes here 
})
app.listen(process.env("X_ZOHO_CATALYST_LISTEN_PORT") || 9000)

Refer Catalyst Node.js SDK help for details. The SDK documentation also provides sample code snippets for all supported functionalities.


Implement Catalyst Python SDK

You can install Catalyst Python SDK for your AppSail solution by executing the following command in your terminal and including it in your app’s source code:

copy
pip install zcatalyst-sdk -t .

You can then import the Python SDK in your code for your Catalyst app. The SDK will need to be initialized with the request object before each request.

An example code snippet for importing and initializing Python SDK in a Flask web app is shown below:

copy
from flask import Flask, request, g
import os
import zcatalyst_sdk
from zcatalyst_sdk.catalyst_app import CatalystApp
app = Flask(__name__)
@app.before_request
def before_request():
    if request.path.startswith('/admin'):
        return 'Unauthorized', 401
    # if authorized user
    g.zc_app = zcatalyst_sdk.initialize(req=request)
@app.route('/')
def index():
    return 'Web App with Python Flask!'
@app.route('/cache')
def cache():
    app: CatalystApp = g.zc_app
    resp = app.cache().segment().put('key', 'value')
    return resp, 200
listen_port = os.getenv('X_ZOHO_CATALYST_LISTEN_PORT', 9000)
app.run(host='0.0.0.0', port = listen_port)

Refer to Catalyst Python SDK help for details about the various functionalities of the SDK toolkit and sample code snippets.

Last Updated 2025-11-03 16:18:29 +0530 IST