---
title: var Requests - API Reference
description: Provides a simple interface for managing data stored in DB Notefiles.
source_url: https://dev.blues.io/api-reference/notecard-api/var-requests/latest/
canonical_url: https://dev.blues.io/api-reference/notecard-api/var-requests/latest/
markdown_url: https://dev.blues.io/api-reference/notecard-api/var-requests/latest.md
---

# var Requests

The `var` APIs provide a simple abstraction over the existing [note.update](https://dev.blues.io/api-reference/notecard-api/note-requests/latest.md#note-update), [note.get](https://dev.blues.io/api-reference/notecard-api/note-requests/latest.md#note-get), and [note.delete](https://dev.blues.io/api-reference/notecard-api/note-requests/latest.md#note-update) APIs for managing data stored in [DB Notefiles](https://dev.blues.io/notecard/notecard-walkthrough/inbound-requests-and-shared-data.md#using-database-files-for-replicated-state).

## var.delete

Supported on

(Cell, Cell+WiFi, LoRa, Skylo, WiFi)

Delete a Note from a **DB Notefile** by its `name`. Provides a simpler interface to the [note.delete](https://dev.blues.io/api-reference/notecard-api/note-requests/latest.md#note-delete) API.

Arguments

### `file`

*string (optional)*

The name of the DB Notefile that contains the Note to delete. Default value is `vars.db`.

### `name`

*string*

The unique Note ID.

**Delete Variable with Default File**

**JSON**

```json
{
  "req": "var.delete",
  "name": "status"
}
```

**C/C++**

```cpp
J *req = NoteNewRequest("var.delete");
JAddStringToObject(req, "name", "status");

NoteRequest(req);
```

**Python**

```python
req = {"req": "var.delete"}
req["name"] = "status"
rsp = card.Transaction(req)
```

Delete a variable named `"status"` from the default `vars.db` DB Notefile.

**Delete Variable with Specific File**

**JSON**

```json
{
  "req": "var.delete",
  "name": "temperature",
  "file": "sensors.db"
}
```

**C/C++**

```cpp
J *req = NoteNewRequest("var.delete");
JAddStringToObject(req, "name", "temperature");
JAddStringToObject(req, "file", "sensors.db");

NoteRequest(req);
```

**Python**

```python
req = {"req": "var.delete"}
req["name"] = "temperature"
req["file"] = "sensors.db"
rsp = card.Transaction(req)
```

Delete a variable named `"temperature"` from the `"sensors.db"` DB Notefile.

**Response Members**

None: an empty object `{}` means success.

## var.get

Supported on

(Cell, Cell+WiFi, LoRa, Skylo, WiFi)

Retrieves a Note from a **DB Notefile**. Provides a simpler interface to the [note.get](https://dev.blues.io/api-reference/notecard-api/note-requests/latest.md#note-get) API.

Arguments

### `file`

*string (optional)*

The name of the DB Notefile that contains the Note to retrieve. Default value is `vars.db`.

### `name`

*string*

The unique Note ID.

**Retrieve Variable with Default File**

**JSON**

```json
{
  "req": "var.get",
  "name": "status"
}
```

**C/C++**

```cpp
J *req = NoteNewRequest("var.get");
JAddStringToObject(req, "name", "status");

NoteRequest(req);
```

**Python**

```python
req = {"req": "var.get"}
req["name"] = "status"
rsp = card.Transaction(req)
```

Retrieve a variable named `"status"` from the default `vars.db` DB Notefile.

**Retrieve Variable with Specific File**

**JSON**

```json
{
  "req": "var.get",
  "name": "temperature",
  "file": "sensors.db"
}
```

**C/C++**

```cpp
J *req = NoteNewRequest("var.get");
JAddStringToObject(req, "name", "temperature");
JAddStringToObject(req, "file", "sensors.db");

NoteRequest(req);
```

**Python**

```python
req = {"req": "var.get"}
req["name"] = "temperature"
req["file"] = "sensors.db"
rsp = card.Transaction(req)
```

Retrieve a variable named `"temperature"` from the `sensors.db` DB Notefile.

**Response Members**

### `flag`

*boolean*

The boolean value stored in the DB Notefile.

### `text`

*string*

The string-based value stored in the DB Notefile.

### `value`

*number*

The numeric value stored in the DB Notefile.

Example Response

```json
{
  "text": "open"
}
```

Response containing a string value from the DB Notefile.

```json
{
  "value": 42
}
```

Response containing a numeric value from the DB Notefile.

```json
{
  "flag": true
}
```

Response containing a boolean value from the DB Notefile.

## var.set

Supported on

(Cell, Cell+WiFi, LoRa, Skylo, WiFi)

Adds or updates a Note in a **DB Notefile**, replacing the existing body with the specified key-value pair where text, value, or flag is the key. Provides a simpler interface to the [note.update](https://dev.blues.io/api-reference/notecard-api/note-requests/latest.md#note-update) API.

Arguments

### `file`

*string (optional)*

The name of the DB Notefile that contains the Note to add or update. Default value is `vars.db`.

### `flag`

*boolean (optional)*

The boolean value to be stored in the DB Notefile.

### `name`

*string*

The unique Note ID.

### `sync`

*boolean (optional)*

Set to `true` to immediately sync any changes.

### `text`

*string (optional)*

The string-based value to be stored in the DB Notefile.

### `value`

*number (optional)*

The numeric value to be stored in the DB Notefile.

**Set Text Variable**

**JSON**

```json
{
  "req": "var.set",
  "name": "status",
  "text": "open"
}
```

**C/C++**

```cpp
J *req = NoteNewRequest("var.set");
JAddStringToObject(req, "name", "status");
JAddStringToObject(req, "text", "open");

NoteRequest(req);
```

**Python**

```python
req = {"req": "var.set"}
req["name"] = "status"
req["text"] = "open"
rsp = card.Transaction(req)
```

Set a text variable named `"status"` to `"open"` in the default `vars.db` DB Notefile.

**Set Numeric Variable**

**JSON**

```json
{
  "req": "var.set",
  "name": "temperature",
  "value": 23.5,
  "file": "sensors.db"
}
```

**C/C++**

```cpp
J *req = NoteNewRequest("var.set");
JAddStringToObject(req, "name", "temperature");
JAddNumberToObject(req, "value", 23.5);
JAddStringToObject(req, "file", "sensors.db");

NoteRequest(req);
```

**Python**

```python
req = {"req": "var.set"}
req["name"] = "temperature"
req["value"] = 23.5
req["file"] = "sensors.db"
rsp = card.Transaction(req)
```

Set a numeric variable named `"temperature"` to `23` in a specific DB Notefile.

**Set Boolean Variable with Sync**

**JSON**

```json
{
  "req": "var.set",
  "name": "active",
  "flag": true,
  "sync": true
}
```

**C/C++**

```cpp
J *req = NoteNewRequest("var.set");
JAddStringToObject(req, "name", "active");
JAddBoolToObject(req, "flag", true);
JAddBoolToObject(req, "sync", true);

NoteRequest(req);
```

**Python**

```python
req = {"req": "var.set"}
req["name"] = "active"
req["flag"] = True
req["sync"] = True
rsp = card.Transaction(req)
```

Set a boolean variable named `"active"` to `true` and immediately sync changes.

**Response Members**

None: an empty object `{}` means success.

[ntn Requests](https://dev.blues.io/api-reference/notecard-api/ntn-requests.md "ntn Requests") [web Requests](https://dev.blues.io/api-reference/notecard-api/web-requests.md "web Requests")
