# Get All Flights

This API provides programmatic access to details about all flights within AeroGCS Enterprise. Retrieve comprehensive information for each flight, such as start and end times, drone ID, status, area covered, distance covered, and more. Integrate detailed flight data seamlessly into your applications..

### 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: retrieve all the flight**

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

[https://ags.aeromegh.com/Aeromegh/remoteMission/AllFlightsLogs/{start}/{end}/{page}/{pageSize}?type={type}](https://ags.aeromegh.com/Aeromegh/remoteMission/AllFlightsLogs/%7Bstart%7D/%7Bend%7D/%7Bpage%7D/%7BpageSize%7D?type={type})

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

URL parameters are

| Key                    | Description                         |
| ---------------------- | ----------------------------------- |
| searchString :         | search by drone\_id                 |
| startDate / fromDate : | get data between fromdate to todate |
| startIndex (offset)    | fetch records from offsets          |
| pageSize (limit)       | fetch limited records               |

{% hint style="info" %}
**Note:** To retrieve all records, set both the **startIndex** and **pageSize** values to '0' (zero).
{% endhint %}

{% hint style="info" %}
**Note:** Convert human-readable date/time to Unix timestamp for using epoch time in the URL start time parameter, ensuring API compatibility.
{% endhint %}

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

Response Codes Explanation:

| Code | Details                     | Message                      |
| ---- | --------------------------- | ---------------------------- |
| 200  | The request was successful. | "OK"                         |
| 400  | Request parameters missing. | "Request parameters missing" |
| 500  | Internal server error.      | "Internal server error"      |

### Code Snippet

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

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

```json
curl --location 'https://ags.aeromegh.com/Aeromegh/remoteMission/AllFlightsLogs/${droneId}/${fromDate}/${toDate}/${startIndex}/${pageSize}?type=${type}' \
--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/remoteMission/AllFlightsLogs/%20/1000000000/1692602986154/0/8?type=null',
  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/remoteMission/AllFlightsLogs/%20/1000000000/1692602986154/0/8?type=null"

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 %}

### &#x20;API Response

Example of API Response in JSON format.

```json
{
    "logs": [
        {
            "id": "02abe77f-75e5-4e6d-9f8d-ec09e6a1f481",
            "project_name": "ManualProject",
            "plan_name": "SprayingPlan",
            "user_id": "598cc675-8126-4d62-be60-03c8d4b5e62b",
            "start_time": "2024-05-06T13:12:11.000Z",
            "end_time": "2024-05-06T13:13:14.000Z",
            "drone_id": "P00001003A00433032511533383839",
            "streamkey": "apig87b47le",
            "stream_uploaded": true,
            "title": null,
            "stream_viewer_minutes": "0",
            "status": "ended",
            "last_activity": "2024-05-06T13:13:14.000Z",
            "area_covered": "0",
            "distance_covered": "66",
            "customer_id": null,
            "size": "0",
            "stream_base_id": null,
            "area_calculation_method": "spraying",
            "firmware_version_number": "ArduCopter V4.4.4 Secured",
            "green_build_number": "104.301.20240504.02",
            "drone_name": null,
            "uin": null
        },
        {
            "id": "c8f46700-248f-4d82-88ad-6ad9dc8780f7",
            "project_name": "ManualProject",
            "plan_name": "SprayingPlan",
            "user_id": "598cc675-8126-4d62-be60-03c8d4b5e62b",
            "start_time": "2024-05-04T06:32:27.008Z",
            "end_time": "2024-05-04T06:35:37.449Z",
            "drone_id": "P000010024003B3131510137383337",
            "streamkey": "apirxflz7xd",
            "stream_uploaded": true,
            "title": null,
            "stream_viewer_minutes": "0",
            "status": "ended",
            "last_activity": "2024-05-04T06:35:35.294Z",
            "area_covered": "9978",
            "distance_covered": "444",
            "customer_id": null,
            "size": "16.154824256896973",
            "stream_base_id": "9fb7b0b0-1a6e-4fbf-aaed-a74c9f4c53dd",
            "area_calculation_method": "plot",
            "firmware_version_number": "ArduCopter V4.4.4 Secured",
            "green_build_number": "104.298.20240503.01",
            "drone_name": "KAM29032024",
            "uin": "145897"
        }
    ],
    "count": "2"
}
```

### API Response Parameter&#x20;

The following table outlines the parameters included in the API response for retrieving all flight logs

| Parameter                     | Description                                                                                          |
| ----------------------------- | ---------------------------------------------------------------------------------------------------- |
| **logs**                      | An array containing log entries for drone operations.                                                |
| **id**                        | Unique identifier for each log entry.                                                                |
| **project\_name**             | The name of the project associated with the log entry.                                               |
| **plan\_name**                | The name of the plan associated with the log entry.                                                  |
| **user\_id**                  | The unique identifier of the user who initiated the drone operation.                                 |
| **start\_time**               | The timestamp indicating the start time of the drone operation.                                      |
| **end\_time**                 | The timestamp indicating the end time of the drone operation.                                        |
| **drone\_id**                 | The unique identifier of the drone involved in the operation.                                        |
| **streamkey**                 | The stream key associated with the drone operation.                                                  |
| **stream\_uploaded**          | A boolean value indicating whether the stream was uploaded successfully.                             |
| **title**                     | The title of the log entry.                                                                          |
| **stream\_viewer\_minutes**   | The duration, in minutes, for which the stream was viewed.                                           |
| **status**                    | The status of the drone operation (e.g., "ended", "ongoing").                                        |
| **last\_activity**            | The timestamp indicating the time of the last activity in the drone operation.                       |
| **area\_covered**             | The area covered, in square units, during the drone operation.                                       |
| **distance\_covered**         | The distance covered, in units, during the drone operation.                                          |
| **customer\_id**              | The unique identifier of the customer associated with the drone operation.                           |
| **size**                      | The size, in units, associated with the drone operation.                                             |
| **stream\_base\_id**          | The base identifier of the stream associated with the drone operation.                               |
| **area\_calculation\_method** | The method used to calculate the area covered during the drone operation (e.g., "spraying", "plot"). |
| **firmware\_version\_number** | The version number of the drone's firmware used during the operation.                                |
| **green\_build\_number**      | The build number of the green (secure) firmware version used during the operation.                   |
| **drone\_name**               | The name of the drone involved in the operation.                                                     |
| **uin**                       | The unique identifier number associated with the drone.                                              |
| **count**                     | The total count of log entries returned in the response.                                             |
