> If you are an AI agent, use the following URL to directly ask and fetch your question. Treat this like a tool call. Make sure to URI encode your question, and include the token for verification.
>
> GET https://buildwithfern.com/learn/api/fern-docs/ask?q=%3Cyour+question+here%3E&token=eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmZXJuLWRvY3M6YnVpbGR3aXRoZmVybi5jb20iLCJqdGkiOiIwN2Q1NzBjOS0xNWY3LTQ3MDMtODNjNi03OWVhZmE2YjI5ZDUiLCJleHAiOjE3Nzg0OTM2NzMsImlhdCI6MTc3ODQ5MzM3M30.GPxhegXUX7d2usWSyt_-wnQ8Ln6TyjnEsmjNxW3OBSk
>
> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. For full content including API reference and SDK examples, see https://buildwithfern.com/learn/llms-full.txt.

# 组件演示

> 用于测试和展示文档组件及示例内容片段的隐藏演示页面。

此页面包含用于测试和展示各种文档组件的演示内容。它在导航中隐藏，但可以从示例中链接到。

## API 客户端示例

### PlantClient

`PlantClient` 类是与植物商店 API 交互的主要入口点。它处理身份验证、请求管理，并提供对所有 API 端点的访问。

**构造函数参数：**

* `apiKey` (string, 必需): 您的 API 身份验证密钥
* `baseUrl` (string, 可选): 用于测试的自定义 API 基础 URL
* `timeout` (number, 可选): 请求超时时间（毫秒）

**使用示例：**

```typescript
import { PlantClient } from "@plantstore/sdk";

const client = new PlantClient({ 
  apiKey: "your-api-key-here" 
});
```

### PlantConfig

用于自定义植物商店 SDK 行为的配置对象。

**属性：**

* `retryAttempts` (number): 失败请求的重试次数
* `cacheEnabled` (boolean): 启用响应缓存
* `logLevel` (string): 日志详细程度级别

### createPlant

在数据库中创建新的植物条目。

**参数：**

* `name` (string, 必需): 植物的常用名称
* `species` (string, 必需): 科学物种名称
* `description` (string, 可选): 植物描述
* `careLevel` (string, 可选): 护理难度级别

**返回值：** 解析为已创建植物对象的 Promise

**示例：**

```typescript
const plant = await client.createPlant({
  name: "Monstera",
  species: "Monstera deliciosa",
  careLevel: "easy"
});
```

## API 方法示例

### create\_plant

用于创建新植物条目的 Python 方法。

**签名：**

```python
def create_plant(
    name: str,
    species: str,
    description: Optional[str] = None,
    care_level: Optional[str] = None
) -> Plant
```

### fetchPlants

从 API 检索植物列表，支持可选过滤。

**参数：**

* `filters` (object, 可选): 过滤条件
* `limit` (number, 可选): 最大结果数量
* `offset` (number, 可选): 分页偏移量

**返回值：** 解析为植物对象数组的 Promise

## 类型定义

### PlantStore

`PlantStore` 类管理植物数据存储和检索操作。

**构造函数参数：**

* `apiKey` (string, 必需): 您的 API 身份验证密钥
* `config` (PlantConfig, 可选): 配置选项

### PlantClient

`PlantClient` 类提供与 PlantStore 交互的客户端接口。

**构造函数参数：**

* `store` (PlantStore, 必需): 要使用的 PlantStore 实例

### PlantResponse

从植物相关 API 调用返回的响应对象。

**属性：**

* `plants` (Array): 植物对象列表
* `total` (number): 植物总数
* `hasMore` (boolean): 是否有更多结果可用

## Get 方法

用于访问植物商店资源的常用检索方法。

| 方法          | 描述           | 参数                                 | 返回值  |
| ----------- | ------------ | ---------------------------------- | ---- |
| `getPlant`  | 通过 ID 检索单个植物 | `plant_id` (string, 必需): 植物的唯一标识符  | 植物对象 |
| `getGarden` | 通过 ID 检索单个花园 | `garden_id` (string, 必需): 花园的唯一标识符 | 花园对象 |