# Get All Pesticides

This API  provides programmatic access to a list of all pesticides, including names, quantities, and other attributes, with secure API key authentication. Use it to seamlessly integrate pesticide data into 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 : Retrieves a list of all pesticides.**

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

{% code overflow="wrap" %}

```url
https://ags.aeromegh.com/Aeromegh/getAllPesticides?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 pesticide name.          | Yes      |                          |
| **fromDateTime** | FromDateTime in UTC.                        | Yes      | 2023-08-19T00:00:20.335Z |
| **toDateTime**   | ToDateTime in UTC.                          | Yes      | 2024-05-07T23:59:20.335Z |
| **orderBy**      | Order by field name (default is pesticide). | Yes      | pesticide                |
| **orderType**    | OrderType is in ASC or DESC (default DESC). | Yes      | DESC                     |
| **pageSize**     | Number of records shown on each page.       | Yes      | 15                       |
| **pageNumber**   | Number of pages 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" %}

```url
curl --location 'https://ags.aeromegh.com/Aeromegh/getAllPesticides?searchString=&fromDateTime=2023-08-19T00%3A00%3A20.335Z&toDateTime=2024-05-07T23%3A59%3A20.335Z&orderBy=pesticide&orderType=DESC&pageSize=15&pageNumber=1' \
--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/getAllPesticides?searchString=&fromDateTime=2023-08-19T00:00:20.335Z&toDateTime=2024-05-07T23:59:20.335Z&orderBy=pesticide&orderType=DESC&pageSize=15&pageNumber=1',
  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/getAllPesticides?searchString=&fromDateTime=2023-08-19T00:00:20.335Z&toDateTime=2024-05-07T23:59:20.335Z&orderBy=pesticide&orderType=DESC&pageSize=15&pageNumber=1"

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
{
    "allpesticide": [
        {
            "pesticide": "Amistar Top"
        },
        {
            "pesticide": "Folio Gold"
        }
    ]
}
```

### API Response Parameter&#x20;

The following parameters are included in API response:

| Parameter     | Description                                    | Example     |
| ------------- | ---------------------------------------------- | ----------- |
| **pesticide** | The type of pesticide returned in the response | Amistar Top |


---

# 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-pesticides.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.
