# Get All Customers

This API provides programmatic access to retrieve all customer records 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 customer's**&#x20;

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

{% code overflow="wrap" %}

```url
https://ags.aeromegh.com/Aeromegh/getAllCustomers?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** | Allows users to search by customer name.              | Yes      | "John Doe"                 |
| **fromDateTime** | Specifies the start date and time in UTC.             | Yes      | "2023-08-19T00:00:20.335Z" |
| **toDateTime**   | Specifies the end date and time in UTC.               | Yes      | "2024-05-07T23:59:20.335Z" |
| **orderBy**      | Specifies the field name to order results by.         | Yes      | "register\_date"           |
| **orderType**    | Specifies the order type; ASC or DESC.                | Yes      | "DESC"                     |
| **pageSize**     | Specifies the number of records per page.             | Yes      | 15                         |
| **pageNumber**   | Specifies the page number; must be 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/getAllCustomers?searchString=&fromDateTime=2023-08-19T00%3A00%3A20.335Z&toDateTime=2024-05-07T23%3A59%3A20.335Z&orderBy=register_date&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/getAllCustomers?searchString=&fromDateTime=2023-08-19T00:00:20.335Z&toDateTime=2024-05-07T23:59:20.335Z&orderBy=register_date&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/getAllCustomers?searchString=&fromDateTime=2023-08-19T00:00:20.335Z&toDateTime=2024-05-07T23:59:20.335Z&orderBy=register_date&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
{
    "allCustomers": [
        {
            "id": "97c4383c-f477-4cb3-8775-727bd0d375ac",
            "userid": "d5dc6351-d96b-49e2-afa8-ff7d509af7aa",
            "customer_name": "chetan shinde",
            "contact_number": null,
            "address": null,
            "email": null,
            "register_date": "2024-04-24T12:14:03.900Z",
            "government_id": null,
            "pilot_license_id": null,
            "gst_no": null,
            "cust_type": "green",
            "totalAcres": "16.5562",
            "totalRevenue": "15405",
            "reportStatCrop": [
                {
                    "crop_type": "rice"
                },
                {
                    "crop_type": "rice "
                },
                {
                    "crop_type": "rics"
                }
            ]
        },
        {
            "id": "8d5fcb25-8e01-44fc-9cff-8a7701f5b326",
            "userid": "d5dc6351-d96b-49e2-afa8-ff7d509af7aa",
            "customer_name": "chetan shinde",
            "contact_number": null,
            "address": null,
            "email": null,
            "register_date": "2024-04-05T09:32:03.498Z",
            "government_id": null,
            "pilot_license_id": null,
            "gst_no": null,
            "cust_type": "green",
            "totalAcres": "2.47",
            "totalRevenue": "100",
            "reportStatCrop": [
                {
                    "crop_type": "rice"
                }
            ]
        }
    ]
}
```

### API Response Parameter&#x20;

The following parameters are included in API response:

| Parameter Name         | Description                                                                                                                                 |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| **id**                 | Unique identifier for each customer.                                                                                                        |
| **userid**             | Identifier for the user associated with the customer.                                                                                       |
| **customer\_name**     | Name of the customer.                                                                                                                       |
| **contact\_number**    | Contact number of the customer.                                                                                                             |
| **address**            | Address of the customer.                                                                                                                    |
| **email**              | Email address of the customer.                                                                                                              |
| **register\_da**te     | Date and time of customer registration.                                                                                                     |
| **government\_id**     | Government-issued identification number, if available.                                                                                      |
| **pilot\_license\_id** | Pilot license ID, if applicable.                                                                                                            |
| **gst\_no**            | Goods and Services Tax (GST) number, if available.                                                                                          |
| **cust\_type**         | Type of customer (e.g., green, premium, standard).                                                                                          |
| **totalAcres**         | Total acres managed by the customer.                                                                                                        |
| **totalRevenue**       | Total revenue generated by the customer.                                                                                                    |
| **reportStatCrop**     | An array containing objects specifying crop types and their statistics for each customer. Each object includes the following subparameters: |
