As enterprises increasingly adopt cloud-native architectures, the need to extend existing systems like SAP S/4HANA, SAP Commerce, and SAP SuccessFactors through custom APIs becomes critical. SAP Kyma, an open-source project built on Kubernetes, offers a powerful way to build, expose, and manage APIs efficiently in a microservices environment. This article guides you through the process of creating and using custom APIs with SAP Kyma, enabling you to seamlessly integrate and extend SAP solutions.
SAP Kyma is a modular and flexible runtime built on Kubernetes, designed for developing and extending applications with microservices and serverless functions. It includes:
Kyma enables developers to build custom APIs that can integrate with SAP and non-SAP systems in a cloud-native way.
Before you begin, ensure the following:
Start by writing a simple Node.js or Python application that exposes a REST API.
Example: Node.js microservice
const express = require('express');
const app = express();
app.get('/api/hello', (req, res) => {
res.json({ message: "Hello from Kyma!" });
});
app.listen(3000, () => {
console.log('Listening on port 3000');
});
Use Docker to build and push the image:
docker build -t <your-docker-id>/kyma-api-service .
docker push <your-docker-id>/kyma-api-service
Create a Kubernetes Deployment and Service manifest:
# kyma-service.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: kyma-api
spec:
replicas: 1
selector:
matchLabels:
app: kyma-api
template:
metadata:
labels:
app: kyma-api
spec:
containers:
- name: kyma-api
image: <your-docker-id>/kyma-api-service
ports:
- containerPort: 3000
---
apiVersion: v1
kind: Service
metadata:
name: kyma-api
spec:
selector:
app: kyma-api
ports:
- port: 80
targetPort: 3000
Apply the manifest:
kubectl apply -f kyma-service.yaml
Define an APIRule to expose the service securely:
# kyma-api-rule.yaml
apiVersion: gateway.kyma-project.io/v1beta1
kind: APIRule
metadata:
name: kyma-api-rule
spec:
service:
name: kyma-api
port: 80
gateway: kyma-gateway.kyma-system.svc.cluster.local
rules:
- path: /.*
methods: ["GET"]
accessStrategies:
- handler: noop
Apply the rule:
kubectl apply -f kyma-api-rule.yaml
Retrieve the external host assigned to your API:
kubectl get apirule kyma-api-rule -o jsonpath='{.status.gateway.url}'
Test the API:
curl https://<gateway-url>/api/hello
You should see:
{ "message": "Hello from Kyma!" }
Imagine you want to integrate SAP Commerce with a custom recommendation engine. You can:
This decoupled architecture ensures SAP systems remain untouched while enabling innovation at scale.
SAP Kyma empowers developers to build, deploy, and manage custom APIs effortlessly in a cloud-native environment. By leveraging Kubernetes and open standards, organizations can extend their SAP landscapes with agility and security. Whether you’re integrating third-party systems or adding new functionality to SAP solutions, custom APIs on Kyma are a modern, scalable choice.