# History

Retrieve the historical power data (production/consumption) for selected date range, in 5 minute intervals.

URL: **`http://LIVEX_IP_ADDRESS/api.php?get=history&from=YYYYMMDD&to=YYYYMMDD`**

Method: **`GET`**

Request Parameters:

* **`from`** - Start date, format `YYYYMMDD`
* **`to`** - (`Optional`) End date, format `YYYYMMDD` (inclusive)

Response Format: **`JSON`**

## Response Example

```javascript
[["2022-10-10 06:58:28",null,5320,null,100,0,0,0,1453,0,1353,0,99,1495,null,null,null,null],["2022-10-10 07:03:39",null,5320,null,100,0,0,0,1643,0,1543,0,99,1682,null,null,null,null],["2022-10-10 07:08:48",null,5320,null,100,0,0,0,1769,0,1665,0,102,1806,null,null,null,null],["2022-10-10 07:13:57",null,5320,null,100,0,0,0,1964,0,1859,0,103,2002,null,null,null,null],["2022-10-10 07:19:07",null,5320,null,100,0,0,0,2105,0,2005,0,99,2147,null,null,null,null],["2022-10-10 07:24:17",null,5320,null,100,0,0,0,2346,0,2246,0,98,2385,null,null,null,null],["2022-10-10 07:29:25",null,5320,null,100,0,0,0,2466,0,2368,0,98,2505,null,null,null,null],["2022-10-10 07:34:36",null,5320,null,100,0,0,0,2243,0,2142,0,99,2288,null,null,null,null],["2022-10-10 07:39:46",null,5320,null,100,0,0,0,2860,0,2766,0,94,2909,null,null,null,null],["2022-10-10 07:44:56",null,5320,null,100,0,0,0,2721,0,2627,0,94,2773,null,null,null,null],["2022-10-10 07:50:05",null,5320,null,100,0,0,0,2845,0,2750,0,93,2902,null,null,null,null],["2022-10-10 07:55:15",null,5320,null,100,0,0,0,3342,0,3254,0,86,3411,null,null,null,null],["2022-10-10 08:00:25",null,5320,null,100,0,0,0,3663,0,3574,0,87,3736,null,null,null,null],["2022-10-10 08:05:35",null,4904,null,98,6603,0,0,10319,0,9981,0,384,4027,null,null,null,null],["2022-10-10 08:10:45",null,4879,null,94,6332,0,0,10304,0,9986,0,367,4279,null,null,null,null],["2022-10-10 08:15:55",null,4876,null,91,6106,0,0,10282,0,9985,0,346,4461,null,null,null,null],["2022-10-10 08:21:05",null,4878,null,87,6007,0,0,10285,0,9987,0,346,4574,null,null,null,null],["2022-10-10 08:26:15",null,4868,null,83,6151,0,0,10287,0,9986,0,351,4423,null,null,null,null],["2022-10-10 08:31:23",null,4864,null,80,5759,0,0,10262,0,9989,0,326,4803,null,null,null,null],["2022-10-10 08:36:32",null,4858,null,76,5512,0,0,10247,0,9986,0,313,5014,null,null,null,null],["2022-10-10 08:41:40",null,4858,null,73,5230,0,0,10235,0,9987,0,300,5274,null,null,null,null],["2022-10-10 08:46:50",null,4854,null,70,5158,0,0,10234,0,9990,0,297,5340,null,null,null,null],["2022-10-10 08:52:01",null,4842,null,66,5764,0,0,10263,0,9992,0,325,4789,null,null,null,null],["2022-10-10 08:57:08",null,4849,null,63,4718,0,0,10207,0,9993,0,270,5750,null,null,null,null],["2022-10-10 09:02:16",null,4849,null,60,4530,0,0,10195,0,9992,0,257,5920,null,null,null,null],["2022-10-10 09:07:26",null,4848,null,58,4653,0,0,10205,0,9993,0,267,5807,null,null,null,null],["2022-10-10 09:12:33",null,4849,null,55,4239,0,0,10184,0,9996,0,243,6205,null,null,null,null],["2022-10-10 09:17:43",null,4848,null,52,4221,0,0,10183,0,9989,0,247,6203,null,null,null,null],["2022-10-10 09:22:52",null,4841,null,50,4436,0,0,10194,0,9990,0,259,6014,null,null,null,null]]
```

## Response Parameters

```
[
    [
        "LOGTIME",
        BATTERY_VOLTAGE_MINUS,
        BATTERY_VOLTAGE_PLUS,
        BATTERY_LEVEL_MINUS,
        BATTERY_LEVEL_PLUS,
        BATTERY_POWER_FROM,
        BATTERY_POWER_TO,
        INPUT_POWER_FROM,
        INPUT_POWER_TO,
        GRID_POWER_FROM,
        GRID_POWER_TO,
        LOAD_POWER,
        HOUSE_POWER,
        SOLAR_POWER,
        EXTSOL_POWER,
        GRIDSOL_POWER,
        EXTSTOR_POWER_FROM,
        EXTSTOR_POWER_TO
    ]
    ...
]
```

**`LOGTIME`** - (`String`) UTC Timestamp when the data was logged.

**`BATTERY_VOLTAGE_MINUS`** - (`Integer` or `null`) Voltage of the negative side of the batteries

**`BATTERY_VOLTAGE_PLUS`** - (`Integer` or `null`) Voltage of the positive side of the batteries

**`BATTERY_LEVEL_MINUS`** - (`Integer` or `null`) Battery level for the negative side of the batteries

**`BATTERY_LEVEL_PLUS`** - (`Integer` or `null`) Battery level for the positive side of the batteries

**`BATTERY_POWER_FROM`** - (`Integer` or `null`) Battery discharging power

**`BATTERY_POWER_TO`** - (`Integer` or `null`) Battery charging power

**`INPUT_POWER_FROM`** - (`Integer` or `null`) Power imported from the input of the UPS

**`INPUT_POWER_TO`** - (`Integer` or `null`) Power exported to the input of the UPS

**`GRID_POWER_FROM`** - (`Integer` or `null`) Power imported from the grid, measured by the Energy Meter

**`GRID_POWER_TO`** - (`Integer` or `null`) Power exported to the grid, measured by the Energy Meter

**`LOAD_POWER`** - (`Integer` or `null`) Power of the protected output

**`HOUSE_POWER`** - (`Integer` or `null`) Power of the unprotected load, connected between the Energy Meter and the UPS Input

**`SOLAR_POWER`** - (`Integer` or `null`) Solar power of the UPS

**`EXTSOL_POWER`** - (`Integer` or `null`) Solar power of external solar devices, measured by Energy Meter

**`GRIDSOL_POWER`** - (`Integer` or `null`) Solar power of external solar device that bypasses the main counter and feeds directly to the grid, measured by Energy Meter

**`EXTSTOR_POWER_FROM`** - (`Integer` or `null`) Power exported from an external storage system (AC-Storage, EV-Charger, etc.), measured by Energy Meter.

**`EXTSTOR_POWER_TO`** - (`Integer` or `null`) Power imported to an external storage system (AC-Storage, EV-Charger, etc.), measured by Energy Meter.

## Examples

#### **`JavaScript Example (jQuery)`**

```javascript
$.get({
    url: "http://LIVEX_IP_ADDRESS/api.php?get=history&from=20190903&to=20190904",
    success: function(response) {
        console.log(response);
    }
});
```

#### **`PHP Example`**

```php
$response = file_get_contents("http://LIVEX_IP_ADDRESS/api.php?get=history&from=20190903&to=20190904");
$jsonArray = json_decode($response, true);
var_dump($jsonArray);
```

#### **`Python Example (requests)`**

```python
import requests
response = requests.get("http://LIVEX_IP_ADDRESS/api.php?get=history&from=20190903&to=20190904")
jsonArray = response.json()
print(jsonArray)
```
