> For the complete documentation index, see [llms.txt](https://docs.maiagent.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.maiagent.ai/maiagent-user-guide/maiagent-user-guide-en/application/integrate/farmingsearch.md).

# Agricultural Data Query

## Use Case: Build a Real-Time Agricultural Data Query Assistant

If you work in agriculture — as a farmer, wholesaler, retailer, or government policy maker — you may need to analyze and forecast market prices and trading trends for various agricultural products (such as rice, fruits, vegetables, livestock products, etc.). By integrating with the publicly available APIs from the Ministry of Agriculture, you can query real-time agricultural product transaction data to perform data analysis and improve decision-making efficiency.

## Workflow

### 1. Create an Agricultural Product Transaction Query Tool

#### Obtain API Configuration

First, visit the API section of the Agricultural Data Open Platform to obtain the data integration source you need.

{% hint style="info" %}
<https://data.moa.gov.tw/api.aspx>
{% endhint %}

Here we use the agricultural product transaction market data as an example for building the tool. In the Parameters section, click the <mark style="color:blue;">"Try it out"</mark> button, then click <mark style="color:blue;">"Execute"</mark> to obtain the API configuration data.

<figure><img src="/files/6NKyiXsNKYTcyjmQJLlM" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/EMeYzMwmOqEihXkbmgaf" alt=""><figcaption></figcaption></figure>

#### Create an API Tool

Go to the MaiAgent platform, click "Tools" in the left sidebar, then click "Add Tool".

<figure><img src="/files/XP4QhI6Zgea6NzElRP9m" alt=""><figcaption></figcaption></figure>

Enter the display name and tool name, select API as the tool type, and fill in the tool description.

For the API configuration below, you can take a screenshot of the API information interface on the Agricultural Data Open Platform and paste it into the MaiAgent Tool Creation Assistant to quickly obtain the API URL, HTTP method, headers, and parameter structure.

{% hint style="info" %}
[Tool Creation AI Assistant](https://chat.maiagent.ai/web-chats/27934296-105a-4f3f-80f0-7e9dcdb638d3)
{% endhint %}

<figure><img src="/files/MA9c4LwqqkD5YVozF8h0" alt=""><figcaption></figcaption></figure>

* API URL example: `https://data.moa.gov.tw/api/v1/AgriProductsTransType/`
* HTTP method example: `GET`
* Headers (JSON) example:

```
{
  "Accept": "application/json"
}
```

* Parameter structure (JSON Schema) example:

```
{
  "type": "object",
  "required": [
    "Start_time",
    "End_time"
  ],
  "properties": {
    "End_time": {
      "type": "string",
      "description": "Query end date (format: ROC calendar year.month.day, e.g., 107.07.10)"
    },
    "Start_time": {
      "type": "string",
      "description": "Query start date (format: ROC calendar year.month.day, e.g., 107.07.01)"
    }
  }
}
```

### 2. Create an Agricultural Data Query AI Assistant

#### Create an AI Assistant

Go to the MaiAgent platform, click "AI Assistants" in the left sidebar, then click "Create AI Assistant".

<figure><img src="/files/AisjrPtN7lIy1zdErGnL" alt=""><figcaption></figcaption></figure>

Select "Agent" as the response mode and enter the role instructions.

<figure><img src="/files/fQi2RswbNUW9TuTLfTu3" alt=""><figcaption></figcaption></figure>

#### Configure Tools for the AI Assistant

Select the "Tools" tab and click <mark style="color:blue;">"+ Select Tool"</mark>.

<figure><img src="/files/Xt3PwnYKPKcgGc4xJad9" alt=""><figcaption></figcaption></figure>

Select the agricultural product transaction query tool you just created and click Confirm.

<figure><img src="/files/zbCV0PHRqnLuYJyFzBPd" alt=""><figcaption></figcaption></figure>

### 3. Deploy the AI Assistant

Now you can ask questions directly through the AI assistant's chat interface to quickly query agricultural product transaction volumes, average price changes, and other information. Stay on top of market prices and trading trends in real time to facilitate further data analysis and improve decision-making efficiency!

<figure><img src="/files/CoVfWA1yu76aG5BQWHDG" alt=""><figcaption></figcaption></figure>

You can also go to the "All Conversations" feature on the MaiAgent platform to view the tool invocation logs when the AI assistant responds.

<figure><img src="/files/tct8PvI9Uy1H9qAjnj4H" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.maiagent.ai/maiagent-user-guide/maiagent-user-guide-en/application/integrate/farmingsearch.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
