Documentation Index
Fetch the complete documentation index at: https://docs.xano.com/llms.txt
Use this file to discover all available pages before exploring further.
Lambda
api.lambda {
code = "return true;"
timeout = 10
} as x2
| 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
api.lambda {
code = "const sum = (a, b) => a + b; return sum(5, 3);"
timeout = 5
} as calculator
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.
Keep your Lambda functions as-is if:
- 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.
Not sure? Ask our Logic Assistant, or your favorite IDE Copilot using our VS Code extension!
External API Request
api.request {
url = "https://www.myapi.com/myApiEndpoint"
method = "GET"
params = {}|set:"a":1
headers = []|array_push:"Authorization: Bearer abc123"
} as api1
| 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
api.request {
url = "https://api.example.com/users"
method = "POST"
params = {}|set:"name":"John"|set:"age":30
headers = []|array_push:"Content-Type: application/json"
} as createUser
This creates an API request that:
- 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
stream.from_request {
as = ""
url = ""
method = "GET"
params = {}
headers = []
timeout = 10
follow_location = true
verify_host = false
verify_peer = false
ca_certificate = ""
certificate = ""
certificate_pass = ""
private_key = ""
private_key_pass = ""
} as stream1
| 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
stream.from_request {
as = "events"
url = "https://api.service.com/stream"
method = "GET"
headers = [
"Authorization: Bearer "|add:$token,
"Accept: text/event-stream"
]
timeout = 30
follow_location = true
} as event_stream
- Creates stream from HTTP request
- Supports SSL/TLS configuration
- Configurable timeout and redirects
- Useful for consuming streaming APIs
Streaming API Response
api.stream {
value = ""
}
| Parameter | Purpose | Example |
|---|
| value | Data to stream | $stream_data, "chunk of data" |
Example
api.stream {
value = $processed_chunk
}
- Streams data to client
- Supports chunked transfer
- Used in server-sent events
- Maintains open connection
Realtime Event
api.realtime_event {
channel = ""
data = ""
auth_table = ""
auth_id = ""
}
| 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
api.realtime_event {
channel = "user:"|add:$user.id
data = {
type: "notification",
message: "New message received",
timestamp: $now
}
auth_table = "users"
auth_id = $user.id
}
- Sends realtime events to clients