Skip to main content

https://mintcdn.com/xano-997cb9ee/GK7krl3WPzHY1W81/images/icons/xs_temp.svg?fit=max&auto=format&n=GK7krl3WPzHY1W81&q=85&s=317ecc913ba93fbb1ced64b38d38b286 Lambda

api.lambda {
  code = "return true;"
  timeout = 10
} as x2
ParameterPurposeExample
codeThe JavaScript or TypeScript code to be executed in the lambda function"return true;"
timeoutThe maximum execution time in seconds before the lambda times out10
asVariable to hold the return of the Lambda functionx2

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!

https://mintcdn.com/xano-997cb9ee/GK7krl3WPzHY1W81/images/icons/xs_temp.svg?fit=max&auto=format&n=GK7krl3WPzHY1W81&q=85&s=317ecc913ba93fbb1ced64b38d38b286 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
ParameterPurposeExample
urlThe endpoint URL to send the request to"https://www.myapi.com/myApiEndpoint"
methodThe HTTP method to use"GET", "POST", "PUT", "DELETE"
paramsQuery parameters or body data to send with the request.`
headersArray of HTTP headers to include in the request`[]
asVariable name to reference this requestapi1

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”

https://mintcdn.com/xano-997cb9ee/GK7krl3WPzHY1W81/images/icons/xs_temp.svg?fit=max&auto=format&n=GK7krl3WPzHY1W81&q=85&s=317ecc913ba93fbb1ced64b38d38b286 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
ParameterPurposeExample
asStream identifier"data_stream", "response_stream"
urlRequest URL"https://api.example.com/stream"
methodHTTP method"GET", "POST", "PUT"
paramsRequest parameters{key: "value"}, {token: $auth.token}
headersRequest headers["Authorization: Bearer token"]
timeoutRequest timeout in seconds10, 30, 60
follow_locationFollow redirectstrue, false
verify_hostVerify SSL hosttrue, false
verify_peerVerify SSL peertrue, false
ca_certificateCA certificate for SSL"ca-cert.pem"
certificateClient certificate"client-cert.pem"
certificate_passCertificate password"certpass"
private_keyPrivate key file"private.key"
private_key_passPrivate key password"keypass"
asAlias for streamstream1, 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

https://mintcdn.com/xano-997cb9ee/GK7krl3WPzHY1W81/images/icons/xs_temp.svg?fit=max&auto=format&n=GK7krl3WPzHY1W81&q=85&s=317ecc913ba93fbb1ced64b38d38b286 Streaming API Response

api.stream {
  value = ""
}
ParameterPurposeExample
valueData 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

https://mintcdn.com/xano-997cb9ee/GK7krl3WPzHY1W81/images/icons/xs_temp.svg?fit=max&auto=format&n=GK7krl3WPzHY1W81&q=85&s=317ecc913ba93fbb1ced64b38d38b286 Realtime Event

api.realtime_event {
  channel = ""
  data = ""
  auth_table = ""
  auth_id = ""
}
ParameterPurposeExample
channelEvent channel name"notifications", "user_123"
dataEvent payload{type: "message", content: "Hello"}
auth_tableAuthorization table"users", "organizations"
auth_idAuthorized 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