# Get All Reports

This API provides programmatic access to retrieve all reports within a specified timeframe based on search criteria, with secure API key authentication. Authorized users can use it for analysis or reference.

### 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 reports**&#x20;

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

{% code overflow="wrap" %}

```json
https://ags.aeromegh.com/Aeromegh/getAllReports?searchString={searchString}&fromDateTime={fromDateTime}&toDateTime={toDateTime}&orderBy={orderBy}&orderType={orderType}&pageSize={pageSize}&pageNumber={pageNumber}
```

{% endcode %}

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

URL parameters are:

| Parameter        | Description                                                     | Optional | Example                  |
| ---------------- | --------------------------------------------------------------- | -------- | ------------------------ |
| **searchString** | User can search by customer name.                               | Yes      | "John Doe"               |
| **fromDateTime** | Start date and time in UTC.                                     | Yes      | 2023-08-19T00:00:20.335Z |
| **toDateTime**   | End date and time in UTC.                                       | Yes      | 2024-05-07T23:59:20.335Z |
| **orderBy**      | Field name to order the results by. Default is `register_date`. | Yes      | "register\_date"         |
| **orderType**    | Order type, either ASC or DESC. Default is DESC.                | Yes      | "DESC"                   |
| **pageSize**     | Number of records to show on each page.                         | Yes      | 15                       |
| **pageNumber**   | Page number, greater than zero.                                 | Yes      | 1                        |

### 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/getAllReports?searchString=t&fromDateTime=2023-08-19T00%3A00%3A20.335Z&toDateTime=2024-05-07T23%3A59%3A20.335Z&orderBy=created_datetime&orderType=DESC&pageSize=15&pageNumber=2' \
--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/getAllReports?searchString=t&fromDateTime=2023-08-19T00:00:20.335Z&toDateTime=2024-05-07T23:59:20.335Z&orderBy=created_datetime&orderType=DESC&pageSize=15&pageNumber=2',
  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/getAllReports?searchString=t&fromDateTime=2023-08-19T00:00:20.335Z&toDateTime=2024-05-07T23:59:20.335Z&orderBy=created_datetime&orderType=DESC&pageSize=15&pageNumber=2"

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
{
    "allReports": [
        {
            "id": "40128c02-993d-4405-bb50-3725a284a056",
            "userid": "d5dc6351-d96b-49e2-afa8-ff7d509af7aa",
            "customer_id": "247052d0-1c49-42b1-aa31-f7212092675c",
            "droneid": "P000010024003B3131510137383337",
            "customer_name": "chetan shinde",
            "project_name": "ManualProject",
            "plan_name": "SprayingPlan",
            "crop_type": "rice",
            "area_percentage": "0",
            "amount": "100",
            "spray_spacing": "3.0",
            "spray_area": "0.2494",
            "flight_time": "00:03:48",
            "created_datetime": "2024-04-05T09:28:20.000Z",
            "pesticide": "water",
            "spray_volume": "600 ml"
        },
        {
            "id": "35f74126-9eb7-4c22-826f-47324508053c",
            "userid": "d5dc6351-d96b-49e2-afa8-ff7d509af7aa",
            "customer_id": "3396b947-6e87-4fa5-a709-0382931b266e",
            "droneid": "P000010024003B3131510137383337",
            "customer_name": "chetan shinde",
            "project_name": "sandip05042024",
            "plan_name": "plan1",
            "crop_type": "rice",
            "area_percentage": "67",
            "amount": "100",
            "spray_spacing": "3.0",
            "spray_area": "0.2559",
            "flight_time": "00:03:46",
            "created_datetime": "2024-04-05T09:16:51.000Z",
            "pesticide": "water",
            "spray_volume": "13790 ml"
        }
    ]
}
```

### API Response Parameter&#x20;

The following parameters are included in the API response:

| Parameter Name        | Description                                                    |
| --------------------- | -------------------------------------------------------------- |
| **id**                | Unique identifier for the report.                              |
| **userid**            | Unique identifier for the user associated with the report.     |
| **customer\_id**      | Unique identifier for the customer associated with the report. |
| **droneid**           | Unique identifier for the drone associated with the report.    |
| **customer\_name**    | Name of the customer associated with the report.               |
| **project\_name**     | Name of the project associated with the report.                |
| **plan\_name**        | Name of the plan associated with the report.                   |
| **crop\_type**        | Type of crop associated with the report.                       |
| **area\_percentage**  | Percentage of area covered by spraying.                        |
| **amount**            | Amount associated with the report.                             |
| **spray\_spacing**    | Spacing used for spraying.                                     |
| **spray\_area**       | Total area covered by spraying.                                |
| **flight\_time**      | Duration of the flight.                                        |
| **created\_datetime** | Date and time when the report was created.                     |
| **pesticide**         | Type of pesticide used.                                        |
| **spray\_volume**     | Volume of spray used.                                          |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://aerogcs-api-docs.aeromegh.com/aerogcs-enterprise-apis/get-all-reports.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
