# Get End Flight

This API facilitates programmatic access to flight session management, enabling authorized users to efficiently terminate flights and gather pertinent information for further analysis.

### 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 Flight Ended Status**

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

{% code overflow="wrap" %}

```url
https://ags.aeromegh.com/Aeromegh/endFlight?flightId={flightId}&teamId={teamId}&distanceCovered={distanceCovered}&areaCovered={areaCovered}

```

{% endcode %}

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

URL parameters are

| Parameter           | Description                                                     |
| ------------------- | --------------------------------------------------------------- |
| **flightId**        | Unique identifier for the flight session.                       |
| **teamId**          | Unique identifier for the team managing the flight.             |
| **distanceCovered** | Distance covered during the flight (in meters).                 |
| **areaCovered**     | Area covered by the drone during the flight (in square meters). |

### 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/endFlight?flightId=1887ab99-f7e2-4926-b5f4-a6341c75e951&teamId=a16afc9b-5205-4fa5-8c42-6276ce1e3281&distanceCovered=12.5&areaCovered=25' \
--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/endFlight?flightId=1887ab99-f7e2-4926-b5f4-a6341c75e951&teamId=a16afc9b-5205-4fa5-8c42-6276ce1e3281&distanceCovered=12.5&areaCovered=25',
  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/endFlight?flightId=1887ab99-f7e2-4926-b5f4-a6341c75e951&teamId=a16afc9b-5205-4fa5-8c42-6276ce1e3281&distanceCovered=12.5&areaCovered=25"

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
{
    "message": "Flight Ended."
}
```

### API Response Parameter&#x20;

The API response provides details about the flight session termination status, including the following parameter:

* **Message**: A textual message indicating the status of the ended flight session.
