# Get Flight Logs

This API provides programmatic access to detailed drone operation information, including telemetry data and flight statuses. Integrate with this API to efficiently retrieve logs for analysis, monitoring, and reporting.

### Authentication&#x20;

To use the API, insert your API key in the Authorization header like this:

```javascript
Authorization: Bearer <YOUR_API_KEY>
```

Replace `<YOUR_API_KEY>` with your AeroGCS API key. Without it, you'll get a 401 Unauthorized error.

### Method

**GET : get flight log**

### HTTP Request <a href="#http-request-33" id="http-request-33"></a>

[<mark style="color:blue;">https://ags.aeromegh.com/AeroMegh/AeroStack/flightLogs/${pageSize}/${offset}?flightID=${flightid}\&keys=${keys}</mark>](https://ags.aeromegh.com/AeroMegh/AeroStack/flightLogs/$%7BpageSize%7D/$%7BpageNumber%7D?flightID=${flightid}\&keys=${keys}\&limit=${limit}\&pagination=${pagination}%22)

### Query Parameters

Query Parameters are

| Key        | Description                                    |
| ---------- | ---------------------------------------------- |
| Flight\_ID | take id from get flights API response          |
| keys       | AS\_FLIGHT\_LOG/AS\_TELE\_DATA/AS\_KEEP\_ALIVE |

### URL Parameters <a href="#http-response-32" id="http-response-32"></a>

URL parameters are

| Key        | Description              |
| ---------- | ------------------------ |
| pageSize : | 20 records on each page  |
| offset :   | page size \* page number |

### HTTP Response <a href="#http-response-32" id="http-response-32"></a>

Response codes explanation:

| Code | Details                    |
| ---- | -------------------------- |
| 200  | message: "ok"              |
| 400  | request parameters missing |
| 500  | internal server error      |

### Code Snippet

Examples of how you can call this API using curl, Node.js, and Python

{% tabs %}
{% tab title="curl" %}

```javascript
  curl --location 'https://ags.aeromegh.com/AeroMegh/AeroStack/flightLogs/${pageSize}/${pageNumber}?flightID=${flightid}&keys=${keys} ' \
--header 'Authorization: Bearer <API_key>'
           
```

{% endtab %}

{% tab title="Node" %}

```javascript
//Please install 'axios' module first
//Set your API key before making the request

const axios = require('axios');

let config = {
  method: 'get',
  maxBodyLength: Infinity,
  url: 'https://ags.aeromegh.com/AeroMegh/AeroStack/flightLogs/0/8?keys=AS_TELE_DATA&flightID=902252eb-f926-47a3-8996-becb7e6d0144',
  headers: { 
    'Authorization': 'Bearer <API_KEY>'
  }
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
//Please install 'requests' package first
//Set your API key before making the request
 import requests

url = "https://ags.aeromegh.com/AeroMegh/AeroStack/flightLogs/0/8?keys=AS_TELE_DATA&flightID=902252eb-f926-47a3-8996-becb7e6d0144"

payload = {}
headers = {
  'Authorization': 'Bearer <API_KEY>'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Note:** Replace **`<API_KEY>`** with the actual API\_KEY provided by Aeromegh.
{% endhint %}

{% hint style="success" %}
**Usage Note** : To specify the type of data you wish to retrieve from the API, set the key accordingly:

* For accessing flight logs, use the key AS\_FLIGHT\_LOG.
* To retrieve telemetry data, set the key as AS\_TELE\_DATA.
* For obtaining keep-alive signals, utilize the key AS\_KEEP\_ALIVE.

Remember, you can only set one key at a time to specify the type of data you want to receive. Choose between AS\_FLIGHT\_LOG, AS\_TELE\_DATA, or AS\_KEEP\_ALIVE based on your requirements.
{% endhint %}

### API Response

Example of API Response in JSON format.

```json
            
              {
                "logs": [
                    {
                        "id": "c50087e9-11b7-48dd-b3f2-f6627abd24f4",
                        "key": "AS_TELE_DATA",
                        "droneid": "P00001DESKTOP-E762V7V",
                        "timestamp": "2023-08-19T12:16:08.000Z",
                        "aerostackid": "21baf594-0400-4afa-a214-dff78990751e",
                        "data": "{\"alt\":\"0.0\",\"bat\":\"12.587\",\"dir\":\"178.00\",\"lat\":\"-35.3638563\",\"lon\":\"149.1655674\",\"mod\":\"4\",\"pit\":\"-0.1300536986872789\",\"rol\":\"-0.6019573781579175\",\"sat\":\"10\",\"vel\":\"0.01667754352092743\",\"yaw\":\"178.28035462124387\",\"timestamp\":\"1692447368\",\"liquidConsumed\":\"00\",\"remainingLiquidPercentage\":\"0\",\"sprayedArea\":\"0.0000\",\"sprayedDistance\":\"0.000\",\"sprayPumpRate\":\"10\",\"flowRate\":\"0\",\"liveObstacleDistance\":\"0\"}",
                        "flight_id": "923dbb64-39e5-4751-88ad-4ef3496f4afa",
                        "totalCount": {
                            "count": "1584"
                        }
                    },
                    {
                        "id": "6ec20f32-b516-4edd-890e-d32011a8dea5",
                        "key": "AS_TELE_DATA",
                        "droneid": "P00001DESKTOP-E762V7V",
                        "timestamp": "2023-08-19T12:16:08.000Z",
                        "aerostackid": "21baf594-0400-4afa-a214-dff78990751e",
                        "data": "{\"alt\":\"0.0\",\"bat\":\"12.587\",\"dir\":\"178.00\",\"lat\":\"-35.3638563\",\"lon\":\"149.1655674\",\"mod\":\"4\",\"pit\":\"-0.1300536986872789\",\"rol\":\"-0.6019573781579175\",\"sat\":\"10\",\"vel\":\"0.016485927626490593\",\"yaw\":\"178.28035462124387\",\"timestamp\":\"1692447368\",\"liquidConsumed\":\"00\",\"remainingLiquidPercentage\":\"0\",\"sprayedArea\":\"0.0000\",\"sprayedDistance\":\"0.000\",\"sprayPumpRate\":\"10\",\"flowRate\":\"0\",\"liveObstacleDistance\":\"0\"}",
                        "flight_id": "923dbb64-39e5-4751-88ad-4ef3496f4afa"
                    },
                    {
                        "id": "a3fb8377-da26-4fc4-94b2-9e78a69a08de",
                        "key": "AS_TELE_DATA",
                        "droneid": "P00001DESKTOP-E762V7V",
                        "timestamp": "2023-08-19T12:16:08.000Z",
                        "aerostackid": "21baf594-0400-4afa-a214-dff78990751e",
                        "data": "{\"alt\":\"0.0\",\"bat\":\"12.587\",\"dir\":\"178.00\",\"lat\":\"-35.3638563\",\"lon\":\"149.1655674\",\"mod\":\"4\",\"pit\":\"-0.1300536986872789\",\"rol\":\"-0.6019573781579175\",\"sat\":\"10\",\"vel\":\"0.016485927626490593\",\"yaw\":\"178.28035462124387\",\"timestamp\":\"1692447368\",\"liquidConsumed\":\"00\",\"remainingLiquidPercentage\":\"0\",\"sprayedArea\":\"0.0000\",\"sprayedDistance\":\"0.000\",\"sprayPumpRate\":\"10\",\"flowRate\":\"0\",\"liveObstacleDistance\":\"0\"}",
                        "flight_id": "923dbb64-39e5-4751-88ad-4ef3496f4afa"
                    }
                ]
            }
```

### API Response Parameter&#x20;

The following parameters are included in the API response for Flight logs

* **id :** Unique identifier for the log
* **key :** Key used to identify if the log entry contains telemetry data or flight data.
* **droneid** : Unique identifier for the drone associated with this log entry
* **timestamp :** Timestamp indicating the time when the telemetry data was recorded.
* **aerostackid :** Identifier associated with an Aerostack system or component.
* **data :** The actual drone data or information captured by the log entry.
  * **Parameters and Units of Measurement**

    The table below outlines the parameters included in the data along with their respective units of measurement:

<table><thead><tr><th>Parameter</th><th>Unit Of Measurement</th><th data-hidden></th></tr></thead><tbody><tr><td>alt</td><td>m (meter)</td><td></td></tr><tr><td>bat</td><td>v (volt)</td><td></td></tr><tr><td>dir</td><td>° (degrees)</td><td></td></tr><tr><td>lat</td><td>° (degrees)</td><td></td></tr><tr><td>lon</td><td>° (degrees)</td><td></td></tr><tr><td>mod</td><td><p>Return as numerical values, where the number represents </p><ol><li>Acro</li><li>Airmode</li><li>Alt Hold</li><li>Auto</li><li>AutoTune</li><li>Brake</li><li>Circle</li><li>Drift</li><li>Flip</li><li>FlowHold</li><li>Follow</li><li>Guided</li><li>Heli_Autorotate</li><li>Land</li><li>Loiter</li><li>PosHold</li><li>RTL</li><li>SmartRTL</li><li>Sport</li><li>Stabilize</li><li>SysID</li><li>Throw</li><li>Turtle</li><li>ZigZag</li></ol></td><td></td></tr><tr><td>pit</td><td>° (degrees)</td><td></td></tr><tr><td>rol</td><td>° (degrees)</td><td></td></tr><tr><td>sat</td><td>satellite count in number</td><td></td></tr><tr><td>vel</td><td>m/s (meter per second)</td><td></td></tr><tr><td>yaw</td><td>° (degrees)</td><td></td></tr><tr><td>timestamp</td><td>ms (milliseconds)</td><td></td></tr><tr><td>liquidConsumed</td><td>ml (milliliter)</td><td></td></tr><tr><td>remainingLiquidPercentage</td><td>% ( percentage)</td><td></td></tr><tr><td>sprayedArea</td><td>m² ( square meter)</td><td></td></tr><tr><td>sprayedDistance</td><td>m ( meter)</td><td></td></tr><tr><td>sprayPumpRate</td><td>% ( percentage)</td><td></td></tr><tr><td>flowRate</td><td>L/min ( liter per minute)</td><td></td></tr><tr><td>liveObstacleDistance</td><td>cm (centimeter)</td><td></td></tr></tbody></table>

* **flight\_id :** Identifier for a specific flight associated with this log entry.
