Back to Blog
Tutorial7 min read2026-05-01

Apache OpenWhisk: Getting Started with Serverless Functions

Apache OpenWhisk is a powerful open-source serverless platform — learn how to write, deploy, and invoke your first function using OpenWhisk on PandaStack.

What Is Apache OpenWhisk?

Apache OpenWhisk is an open-source, distributed serverless platform that executes functions in response to events. It supports multiple runtimes including Node.js and Python, making it flexible for a wide range of backend workloads.

PandaStack's edge functions are powered by Apache OpenWhisk, giving you all the benefits of the OpenWhisk execution model without the operational complexity of running the platform yourself. You write the function, PandaStack handles the rest.

How OpenWhisk Works

OpenWhisk is built around a few core concepts:

  • Actions — Individual functions (what PandaStack calls edge functions)
  • Triggers — Event sources that fire when something happens
  • Rules — Mappings between triggers and actions
  • Packages — Groups of related actions

For most web developers, you will work primarily with Actions invoked over HTTP. The runtime receives your function, wraps it in a container, executes it with the provided parameters, and returns the result.

Writing Your First OpenWhisk-Compatible Function

OpenWhisk expects a specific function signature. Your handler must be named main and must return an object (or a Promise that resolves to one).

Node.js:

// hello.js
const main = (params) => {
  const name = params.name || 'Developer';
  const language = params.language || 'JavaScript';

  return {
    statusCode: 200,
    body: JSON.stringify({
      message: `Hello ${name}! You are writing ${language}.`,
      timestamp: new Date().toISOString()
    })
  };
};

module.exports = { main };

Python:

# hello.py
import json
from datetime import datetime

def main(params):
    name = params.get('name', 'Developer')
    language = params.get('language', 'Python')

    return {
        'statusCode': 200,
        'body': json.dumps({
            'message': f'Hello {name}! You are writing {language}.',
            'timestamp': datetime.utcnow().isoformat()
        })
    }

Both functions follow the same contract: accept a params dict/object, return a response object with statusCode and body.

Deploying to PandaStack

Install the PandaStack CLI and deploy your function:

# Install the CLI
npm install -g @pandastack/cli

# Authenticate
panda login

# Deploy Node.js function
panda functions deploy ./hello.js --name hello-world --runtime nodejs

# Deploy Python function
panda functions deploy ./hello.py --name hello-world-py --runtime python

After deployment, you will receive an HTTPS endpoint:

https://functions.pandastack.io/api/v1/namespaces/_/actions/hello-world

Invoking Your Function

Invoke your function with a simple HTTP request:

curl -X POST https://functions.pandastack.io/api/v1/namespaces/_/actions/hello-world   -H "Content-Type: application/json"   -d '{"name": "Alice", "language": "JavaScript"}'

Response:

{
  "message": "Hello Alice! You are writing JavaScript.",
  "timestamp": "2026-05-15T10:30:00.000Z"
}

You can also invoke using the CLI:

panda functions invoke hello-world --param name Alice --param language JavaScript

Working with Async Functions

OpenWhisk supports async/await in Node.js. Use it freely for database queries, API calls, or any I/O-bound work:

// fetchUser.js
const https = require('https');

const fetchJson = (url) => new Promise((resolve, reject) => {
  https.get(url, (res) => {
    let data = '';
    res.on('data', chunk => data += chunk);
    res.on('end', () => resolve(JSON.parse(data)));
  }).on('error', reject);
});

const main = async (params) => {
  const userId = params.userId;
  if (!userId) {
    return { statusCode: 400, body: JSON.stringify({ error: 'userId required' }) };
  }

  const user = await fetchJson(`https://jsonplaceholder.typicode.com/users/${userId}`);
  return {
    statusCode: 200,
    body: JSON.stringify({ user })
  };
};

module.exports = { main };

Environment Variables and Secrets

Pass configuration to your function as default parameters (stored securely, not in your code):

panda functions deploy ./fetchUser.js   --name fetch-user   --runtime nodejs   --param DB_URL "$DATABASE_URL"   --param API_KEY "$THIRD_PARTY_KEY"

These parameters are merged with the invocation parameters on every call.

Viewing Logs and Monitoring

After invoking your function, view logs from the CLI or dashboard:

panda functions logs hello-world

For a full view of invocation history, response times, and error rates, visit dashboard.pandastack.io. Documentation for all OpenWhisk runtime capabilities is at docs.pandastack.io.

Conclusion

Apache OpenWhisk provides a robust, open-source foundation for serverless execution. PandaStack wraps it in a developer-friendly experience: write your function, deploy with one command, and invoke it over HTTP. Whether you are building a lean API, a webhook handler, or a data transformer, OpenWhisk on PandaStack gets you there fast.

Ready to deploy?

Start free on PandaStack — no credit card required.

Start free on PandaStack

More in Tutorial

Browse all Tutorial articles →

See also