---
id: "M:cAlgo.API.LocalStorage.GetString(System.String)"
kind: "method"
type: "T:cAlgo.API.LocalStorage"
url: "https://help.ctrader.com/ctrader-algo/references/Localstorage/LocalStorage/GetString/"
---

> Documentation index for agents: https://help.ctrader.com/ctrader-algo/llms.txt · machine index: https://help.ctrader.com/ctrader-algo/api.json

# LocalStorage.GetString

Member of [LocalStorage](https://help.ctrader.com/ctrader-algo/references/Localstorage/LocalStorage/index.md).

## GetString(string key)

Gets a string value from local storage. This method will search all available scopes (Instance -&gt; Type -&gt; Device) and stops on first found value.

Environments: Desktop supported · CLI supported · Cloud works differently.

- Cloud: Key not set in this run returns null and sends LocalStorageException 'Getting local storage data from file is not supported in cloud environment.' to OnException.

C#:

```csharp
string GetString(string key)
```

Python:

```python
api.LocalStorage.GetString(key: str) -> str
```

### Parameters

- `key` (`string`, Python `str`): The key of the element to get, max length for keys is 50 characters, and only alphanumeric and space characters are allowed, you can only use space in the middle of key not at the start or end

### Returns

`string` — The requested value or an empty string if the provided key is not found

### Examples

C#:

```csharp
var lastSignal = LocalStorage.GetString("Last Signal");
if (string.IsNullOrEmpty(lastSignal))
    Print("No signal stored yet");
else
    Print("Last signal: {0}", lastSignal);
```

Python:

```python
lastSignal = api.LocalStorage.GetString("Last Signal")
if not lastSignal:
    api.Print("No signal stored yet")
else:
    api.Print(f"Last signal: {lastSignal}")
```

## GetString(string key, LocalStorageScope localStorageScope)

Gets a string value from local storage.

Environments: Desktop supported · CLI supported · Cloud works differently.

- Cloud: Key not set in this run returns null and sends LocalStorageException 'Getting local storage data from file is not supported in cloud environment.' to OnException.

C#:

```csharp
string GetString(string key, LocalStorageScope localStorageScope)
```

Python:

```python
api.LocalStorage.GetString(key: str, localStorageScope: LocalStorageScope) -> str
```

### Parameters

- `key` (`string`, Python `str`): The key of the element to get, max length for keys is 50 characters, and only alphanumeric and space characters are allowed, you can only use space in the middle of key not at the start or end
- `localStorageScope` (`LocalStorageScope`, Python `LocalStorageScope`): The storage scope of the element

### Returns

`string` — The requested value or an empty string if the provided key is not found

### Examples

C#:

```csharp
var lastSignal = LocalStorage.GetString("Last Signal", LocalStorageScope.Device);
Print("Last signal on this device: {0}", lastSignal);
```

Python:

```python
lastSignal = api.LocalStorage.GetString("Last Signal", LocalStorageScope.Device)
api.Print(f"Last signal on this device: {lastSignal}")
```

