Lambda
| Parameter | Purpose | Example |
|---|---|---|
| code | The JavaScript or TypeScript code to be executed in the lambda function | "return true;" |
| timeout | The maximum execution time in seconds before the lambda times out | 10 |
| as | Variable to hold the return of the Lambda function | x2 |
Example
When should I use XanoScript instead of Lambda functions, or should I migrate my existing Lambdas to XanoScript?
Lambda functions in Xano are self-contained pieces of code written in JavaScript or TypeScript. They’re ideal for solving edge cases that can’t be easily addressed using the visual builder—such as performing complex cryptography, integrating with niche APIs, or leveraging specific NPM packages. While Lambdas offer flexibility and access to the wider JS ecosystem, they can create challenges for collaboration, visibility, and maintainability—especially when your team relies on the visual builder or XanoScript for most backend logic. You should consider migrating your Lambda functions to XanoScript if one or more of the following apply:- The Lambda performs logic that can already be handled with native Xano functions or the visual builder.
- Your non-technical team members need visibility into what the function is doing.
- You want your backend to be fully consistent and transparent—useful for both AI-assisted development and long-term maintainability.
- They depend on NPM packages or external libraries.
- They perform cryptographic or computational tasks not possible with native Xano functions.
- They’re isolated, well-documented, and don’t require broader team visibility.
External API Request
| Parameter | Purpose | Example |
|---|---|---|
| url | The endpoint URL to send the request to | "https://www.myapi.com/myApiEndpoint" |
| method | The HTTP method to use | "GET", "POST", "PUT", "DELETE" |
| params | Query parameters or body data to send with the request. | ` |
| headers | Array of HTTP headers to include in the request | `[] |
| as | Variable name to reference this request | api1 |
Example
- Sends a POST request to the specified URL
- Includes query parameters or body data
- Sets custom headers
- Can be referenced using the alias “createUser”
Streaming API Request
| Parameter | Purpose | Example |
|---|---|---|
| as | Stream identifier | "data_stream", "response_stream" |
| url | Request URL | "https://api.example.com/stream" |
| method | HTTP method | "GET", "POST", "PUT" |
| params | Request parameters | {key: "value"}, {token: $auth.token} |
| headers | Request headers | ["Authorization: Bearer token"] |
| timeout | Request timeout in seconds | 10, 30, 60 |
| follow_location | Follow redirects | true, false |
| verify_host | Verify SSL host | true, false |
| verify_peer | Verify SSL peer | true, false |
| ca_certificate | CA certificate for SSL | "ca-cert.pem" |
| certificate | Client certificate | "client-cert.pem" |
| certificate_pass | Certificate password | "certpass" |
| private_key | Private key file | "private.key" |
| private_key_pass | Private key password | "keypass" |
| as | Alias for stream | stream1, http_stream |
Example
- Creates stream from HTTP request
- Supports SSL/TLS configuration
- Configurable timeout and redirects
- Useful for consuming streaming APIs
Streaming API Response
| Parameter | Purpose | Example |
|---|---|---|
| value | Data to stream | $stream_data, "chunk of data" |
Example
- Streams data to client
- Supports chunked transfer
- Used in server-sent events
- Maintains open connection
Realtime Event
| Parameter | Purpose | Example |
|---|---|---|
| channel | Event channel name | "notifications", "user_123" |
| data | Event payload | {type: "message", content: "Hello"} |
| auth_table | Authorization table | "users", "organizations" |
| auth_id | Authorized entity ID | "123", $user.id |
Example
- Sends realtime events to clients