Xano Documentation
Search…
Variables
Variables are containers that hold information. Their sole purpose is to label and store data in memory to be sent to your front-end or used in another function.
Variables are one of the most important concepts to understand in Xano. You can think of Variables as containers that hold information. Their sole purpose is to label and store data in memory to be sent to your front-end or used in another function.
Variables can be stored as different types and are represented in orange in the function stack. Here's an example of a variable being returned from a Query all Records function:
The company variable that gets returned might look something like this:
1
[
2
{
3
"id":1,
4
"created_at":1617150333684,
5
"name":"Xano"
6
},
7
{
8
"id":2,
9
"created_at":1617150415014,
10
"name":"Google"
11
}
12
]
Copied!
So if you were building an app that was displaying companies from your Database and this was sufficient, you would set this variable company to be returned as the API response.
As stated in the Function Stack section, Variables are passed through each function in the function stack. So in the example below you can see variables being passed through the stack:\

How do variables work in the example above?

The above Function Stack goes through each item in the variable company using a For Each Loop and creates a new variable called individual_company to represent each company in the company variable. There is then a Conditional function that uses dot notation to access the individual name of the company (individual_company.name) and says that if the Company name = Xano then create a new variable called success_message that says "Xano is amazing!"

Variable Types

Text

Text is the most common and flexible field type. You can store anything from short names, to long paragraphs of text with emojis. You can even store raw HTML.

Array

An array is an order collection of items that can be iterated through like ["dog", "cat" , "bird", ...]

Object

An object is a collection of properties with key: value pairs. If we take a car for example an object might look like: { "make": "honda", "model: "civic", "year": 2005, "color": "black" }

Integer

The integer field type is specifically designed to hold numbers without decimals like 1, 2, 3 or -1, 2, 3.

Decimal

The decimal type is when you really want to be specific and store numbers defined by its precision. Like Pi - 3.14159265...

Boolean (True/False)

A boolean value is either true or false. This sets a definitive boolean value of true.

Timestamp (Epoch)

Timestamps are stored as a unix timestamp in milliseconds and we've written extensively about how to use timestamps in Xano. In the input box if you specify NOW, it represents the time it is when this function is executed.

Null

A NULL value is a special marker used to indicate that a data value does not exist. In other words, it is just a placeholder to denote values that are missing or that we do not know.

Environment Variables

$http_headers

These headers are used to pass information between the front-end calling your API and your backend.

$remote_ip

This is a special environment variable that resolves to the IP address of the individual accessing the API Endpoint.

$request_uri

This is a special environment variable that contains the URI that is being accessed from the API.

$request_querystring

This is a special environment variable that contains the query string of the URI that is being accessed from the API.

Adding Custom Environment Variables

Add Environment variables to your Xano Workspace to have them accessible everywhere. This is the safe way to store sensitive API keys or identifying information so you don't have to hard code it into any API endpoint that you do.
Last modified 1mo ago