Component demos

This page contains demo content for testing and showcasing various documentation components. It’s hidden from navigation but can be linked to from examples.

API client examples

PlantClient

The PlantClient class is the main entry point for interacting with the Plant Store API. It handles authentication, request management, and provides access to all API endpoints.

Constructor parameters:

  • apiKey (string, required): Your API authentication key
  • baseUrl (string, optional): Custom API base URL for testing
  • timeout (number, optional): Request timeout in milliseconds

Example usage:

1import { PlantClient } from "@plantstore/sdk";
2
3const client = new PlantClient({
4 apiKey: "your-api-key-here"
5});

PlantConfig

Configuration object for customizing the Plant Store SDK behavior.

Properties:

  • retryAttempts (number): Number of retry attempts for failed requests
  • cacheEnabled (boolean): Enable response caching
  • logLevel (string): Logging verbosity level

createPlant

Creates a new plant entry in the database.

Parameters:

  • name (string, required): Common name of the plant
  • species (string, required): Scientific species name
  • description (string, optional): Plant description
  • careLevel (string, optional): Care difficulty level

Returns: Promise resolving to the created plant object

Example:

1const plant = await client.createPlant({
2 name: "Monstera",
3 species: "Monstera deliciosa",
4 careLevel: "easy"
5});

API method examples

create_plant

Python method for creating a new plant entry.

Signature:

1def create_plant(
2 name: str,
3 species: str,
4 description: Optional[str] = None,
5 care_level: Optional[str] = None
6) -> Plant

fetchPlants

Retrieves a list of plants from the API with optional filtering.

Parameters:

  • filters (object, optional): Filter criteria
  • limit (number, optional): Maximum number of results
  • offset (number, optional): Pagination offset

Returns: Promise resolving to an array of plant objects

Type definitions

PlantStore

The PlantStore class manages plant data storage and retrieval operations.

Constructor parameters:

  • apiKey (string, required): Your API authentication key
  • config (PlantConfig, optional): Configuration options

PlantClient

The PlantClient class provides a client interface for interacting with PlantStore.

Constructor parameters:

  • store (PlantStore, required): PlantStore instance to use

PlantResponse

Response object returned from plant-related API calls.

Properties:

  • plants (Array): List of plant objects
  • total (number): Total count of plants
  • hasMore (boolean): Whether more results are available

Get methods

Common retrieval methods for accessing plant store resources.

MethodDescriptionParametersReturns
getPlantRetrieves a single plant by its IDplant_id (string, required): The unique identifier of the plantPlant object
getGardenRetrieves a single garden by its IDgarden_id (string, required): The unique identifier of the gardenGarden object