{
  "openapi": "3.1.0",
  "info": {
    "title": "EcoPlot API",
    "version": "1.1.1",
    "summary": "Plant and regional-ecology knowledge for design and land-stewardship apps.",
    "description": "The EcoPlot API gives partner apps the plant and regional-ecology knowledge\nbehind [EcoPlot](https://plantgroup.co), PLANT Group's land-stewardship app.\n\nTwo endpoints do the work:\n\n- **`POST /v1/site-ecology`**: describe a place in a few words (\"Ames, Iowa\",\n  a ZIP code, or a street address) or with coordinates. The response gives:\n  - USDA hardiness zone, frost dates and rainfall\n  - soil and ecoregion\n  - a palette of plants native to the region, grouped by growth form, with\n    bloom colour, bloom months and mature height\n  - invasive plants to avoid\n  - the plants most recorded nearby\n- **`GET /v1/species`**: look up one plant. The response gives:\n  - its native range\n  - a short profile\n  - pet and livestock toxicity\n  - bloom facts\n  - reference photos\n\n  The photos are useful as visual references for image models, so that\n  rendered plants look like the real species.\n\n## Authentication\n\nEvery request needs an API key, sent in the `x-api-key` header\n(`Authorization: Bearer <key>` also works). Keys look like\n`ek_live_…`; PLANT Group issues them to partners. Keep keys server-side.\nThe API is for server-to-server use, so never ship a key in a mobile app or\nweb page.\n\n## Free for schools and universities\n\nAPI access is free for schools and universities, for\nteaching, student projects and research. Request a key at\n[ecoplot.app/api-access.html](https://ecoplot.app/api-access.html) and tell\nus your school or university and what you plan to build.\n\n## Rate limits\n\n- **Per minute:** 60 requests per key.\n- **Per day:** each key has a daily limit (2,000 by default).\n- **When you go over:** the API returns `429` with a `Retry-After` header\n  (seconds) and a `retry_after` field in the error body.\n- **What counts:** every request, including rejected ones.\n\n## Speed and caching\n\n- **First lookup for an area:** a site-ecology answer gathers about nine\n  public data sources in parallel and usually takes 5–15 seconds. The\n  first lookups in a new state or province can take up to ~30 seconds\n  while its plants' growth forms are classified (once, then cached for\n  everyone).\n- **Repeat lookups:** answers for the same ~1 km area are cached for 30\n  days and come back in under a second (`cached: true`).\n- **Species:** the first request for a plant rates its candidate photos\n  and takes roughly 5–15 seconds; the result is cached for 90 days.\n- **Timeouts:** allow at least 45 seconds.\n\n## Coverage\n\n- **US and Canada:** native ranges and invasive status come from EcoPlot's\n  species catalog, which covers the US (by state) and Canada (by province).\n- **United States only:** soil (USDA SSURGO), ecoregion (US EPA) and the\n  official USDA hardiness zone (by ZIP code).\n- **Everywhere else:** `coverage` is `\"limited\"` and there's no curated\n  palette. You still get climate, an approximate hardiness zone, and the\n  plants recorded nearby (native status unknown).\n- **Always read `notes`:** it says plainly what's missing or approximate.\n\n## Attribution\n\nSite-ecology responses include an `attribution` list. Every photo,\nwhether from EcoPlot's catalog or from iNaturalist, carries its own\n`license` and `attribution`.\n\n- **Photo licences:** limited to CC0 / public domain, CC BY and\n  CC BY-SA, so every photo may be used commercially. Photos that are\n  non-commercial, no-derivatives, all-rights-reserved or of unknown licence\n  are never returned.\n- **Crediting:** if you show data or photos to people, credit the sources\n  as listed, for example OpenStreetMap contributors (ODbL), GeoNames and\n  Open-Meteo (CC BY 4.0), GBIF.org, and each photographer.\n\n## Errors\n\nEvery error has the same shape:\n\n```json\n{ \"error\": { \"code\": \"place_not_found\", \"message\": \"Couldn't find \\\"Atlantis\\\". Try a city and state/country, a ZIP code, or an address.\" } }\n```\n\n| Status | `code` | Meaning |\n|---|---|---|\n| 400 | `bad_request` | Missing or invalid parameters. |\n| 401 | `missing_key`, `invalid_key` | No API key, or not a valid one. |\n| 403 | `key_disabled`, `forbidden` | The key was turned off, or can't use this endpoint. |\n| 404 | `place_not_found`, `species_not_found`, `not_found` | Nothing matched, or unknown endpoint. |\n| 429 | `rate_limited`, `daily_limit` | Too many requests; see `Retry-After`. |\n| 500 | `internal` | Something went wrong on our side. |\n| 503 | `geocoder_unavailable`, `unavailable` | A dependency is down; retry shortly. |\n\n## Changelog\n\n- **1.1.1:** The API is served at `https://api.ecoplot.app`. The Supabase\n  function URL still works.\n- **1.1.0:**\n  - Photos are licence-checked: CC0, CC BY and CC BY-SA only, with\n    `license` always set.\n  - Photos are rated by a vision model and ordered: the whole plant in\n    bloom first, then a flower close-up. New `view` and `in_bloom` fields.\n  - Growth forms are classified per species, with a new `vine` form.\n  - Garden-unsuitable natives are excluded from the palette.\n  - Place lookup falls back across Photon, Census, GeoNames and Nominatim.\n- **1.0.0:** First release: `/v1/health`, `/v1/site-ecology`,\n  `/v1/species`.\n",
    "contact": {
      "name": "PLANT Group",
      "email": "support@plantgroup.co",
      "url": "https://plantgroup.co"
    }
  },
  "servers": [
    {
      "url": "https://api.ecoplot.app",
      "description": "Production"
    },
    {
      "url": "https://dvylxeuzcpctqbnlafbb.supabase.co/functions/v1/ecoplot-api",
      "description": "Production, direct to the function (same API, same keys)"
    }
  ],
  "security": [
    {
      "ApiKeyHeader": []
    },
    {
      "BearerKey": []
    }
  ],
  "tags": [
    {
      "name": "Site ecology",
      "description": "A place → its climate, soil, ecoregion and native plants."
    },
    {
      "name": "Species",
      "description": "One plant → profile, toxicity, bloom and reference photos."
    },
    {
      "name": "Service",
      "description": "Health check."
    }
  ],
  "paths": {
    "/v1/health": {
      "get": {
        "tags": [
          "Service"
        ],
        "operationId": "getHealth",
        "summary": "Check the API and your key",
        "description": "Returns `ok` and the name of the client the key belongs to. Counts toward rate limits.",
        "responses": {
          "200": {
            "description": "The API is up and the key is valid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "client"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "const": true
                    },
                    "client": {
                      "type": "string",
                      "description": "Name of the partner the key was issued to., examples: [Formscape]"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/site-ecology": {
      "post": {
        "tags": [
          "Site ecology"
        ],
        "operationId": "getSiteEcology",
        "summary": "Regional ecology and a native plant palette for a place",
        "description": "Send either `place` (free text) or `lat` + `lon`. Free text can be a\ncity with its state or country, a ZIP or postcode, or a street address;\nthe response's `place` shows what it was matched to, and\n`alternatives` lists other matches, so check you got the right\nSpringfield.\n\n**Palette ranking:** within each growth form, plants are ranked as\nfollows:\n1. recorded within ~10 km\n2. commonly recorded within ~60 km\n3. merely listed for the state\n\nA photo breaks ties. Invasive plants never appear in the palette. Nor\ndo natives that don't belong in a garden: plants that cause rashes or\nserious allergies (poison ivy, ragweed, nettles), parasites (dodder),\naggressive weeds, and aquatic-only plants.\n\n**Growth forms:** `tree`, `shrub`, `grass` (grasses, sedges and\nrushes), `forb` (wildflowers, ferns and other herbaceous plants) and\n`vine` (climbing and trailing vines). Each plant's form is classified\nonce by a botanist-prompted model and cached.\n**Place lookup:** free text is matched with OpenStreetMap geocoders\n(Photon, then Nominatim), the US Census geocoder for US street\naddresses, and GeoNames (via Open-Meteo) for cities and ZIP codes.\nUS places also get their ZIP and state from the Census geocoder,\nwhich is what the official hardiness zone and native list are\nlooked up by.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SiteEcologyRequest"
              },
              "examples": {
                "city": {
                  "summary": "A city",
                  "value": {
                    "place": "Ames, Iowa"
                  }
                },
                "zip": {
                  "summary": "A US ZIP code, grasses and wildflowers only",
                  "value": {
                    "place": "78704",
                    "forms": [
                      "grass",
                      "forb"
                    ],
                    "per_form": 12
                  }
                },
                "coordinates": {
                  "summary": "Coordinates",
                  "value": {
                    "lat": 42.0267,
                    "lon": -93.617
                  }
                },
                "international": {
                  "summary": "Outside the US and Canada (limited coverage)",
                  "value": {
                    "place": "San Cristóbal de las Casas, Chiapas"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The place's ecology.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SiteEcology"
                },
                "examples": {
                  "ames": {
                    "summary": "Ames, Iowa (abridged)",
                    "value": {
                      "place": {
                        "name": "Ames, Story County, Iowa, United States",
                        "lat": 42.03471,
                        "lon": -93.61994,
                        "precision": "city",
                        "country": "US",
                        "state": "IA",
                        "state_name": "Iowa",
                        "county": "Story County"
                      },
                      "alternatives": [
                        "Ames, Major County, Oklahoma, United States"
                      ],
                      "coverage": "full",
                      "hardiness_zone": {
                        "zone": "5b",
                        "system": "USDA",
                        "source": "USDA Plant Hardiness Zone Map 2023 (by ZIP)"
                      },
                      "ecoregion": {
                        "level4": "Des Moines Lobe",
                        "level3": "Western Corn Belt Plains",
                        "level2": "Temperate Prairies",
                        "level1": "Great Plains",
                        "source": "US EPA Level III/IV Ecoregions"
                      },
                      "climate": {
                        "annual_precip_mm": 937,
                        "annual_precip_in": 36.9,
                        "warmest_month": {
                          "month": "Jul",
                          "avg_high_c": 28.7,
                          "avg_high_f": 83.6
                        },
                        "coldest_month": {
                          "month": "Jan",
                          "avg_low_c": -10.5,
                          "avg_low_f": 13
                        },
                        "last_spring_frost": "Apr 19",
                        "first_fall_frost": "Oct 22",
                        "frost_free_days": 186,
                        "frost_years": 10,
                        "frost_free_climate": false,
                        "elevation_m": 285,
                        "years": 10,
                        "source": "Open-Meteo historical weather (ERA5 reanalysis, ~10 km grid)"
                      },
                      "soil": {
                        "texture": "Loam",
                        "ph": 6.6,
                        "organic_matter_pct": 6.33,
                        "drainage": "Poorly drained",
                        "sand_pct": 22.6,
                        "silt_pct": 45.4,
                        "clay_pct": 32.1,
                        "slope_pct": 1,
                        "water_holding_in_30cm": 2.16,
                        "soil_series": [
                          "Webster"
                        ],
                        "depth_cm": 30,
                        "source": "USDA NRCS SSURGO"
                      },
                      "palette": {
                        "tree": [
                          {
                            "name": "Bur Oak",
                            "scientific": "Quercus macrocarpa",
                            "native_here": true,
                            "observed_nearby": false,
                            "bloom": {
                              "color": "#9acd32",
                              "color_name": "light green",
                              "months": [
                                5
                              ],
                              "height_m": 25
                            },
                            "image_url": "https://plantgroup-landplanner-species.s3.amazonaws.com/species/plants/…/0.jpg"
                          }
                        ],
                        "forb": [
                          {
                            "name": "Butterflyweed",
                            "scientific": "Asclepias tuberosa",
                            "native_here": true,
                            "observed_nearby": true,
                            "bloom": {
                              "color": "#f28c28",
                              "color_name": "orange",
                              "months": [
                                6,
                                7,
                                8
                              ],
                              "height_m": 0.6
                            },
                            "image_url": null
                          }
                        ],
                        "shrub": [],
                        "grass": [],
                        "vine": []
                      },
                      "avoid": [
                        {
                          "name": "Garlic Mustard",
                          "scientific": "Alliaria petiolata",
                          "observed_nearby": true,
                          "why": "Pull before seed set; remove from site."
                        }
                      ],
                      "observed_nearby": [
                        {
                          "name": "Dicentra cucullaria",
                          "scientific": "Dicentra cucullaria",
                          "records": 369,
                          "native_here": "unknown",
                          "invasive_here": false
                        },
                        {
                          "name": "Common Milkweed",
                          "scientific": "Asclepias syriaca",
                          "records": 129,
                          "native_here": true,
                          "invasive_here": false
                        }
                      ],
                      "notes": [
                        "Soil is the survey's typical soil near the centre of Ames; a specific lot may differ — a soil test is worth it."
                      ],
                      "attribution": [
                        "Place lookup: © OpenStreetMap contributors (ODbL), GeoNames (CC BY 4.0), US Census Bureau",
                        "Weather history: Open-Meteo.com (CC BY 4.0), ERA5",
                        "Hardiness zone: USDA Plant Hardiness Zone Map 2023 via phzmapi.org",
                        "Soil: USDA NRCS Soil Survey Geographic Database (SSURGO)",
                        "Ecoregions: US EPA Level III/IV",
                        "Plant records: GBIF.org",
                        "Native ranges and invasive status: EcoPlot species catalog"
                      ],
                      "cached": false
                    }
                  },
                  "chiapas": {
                    "summary": "San Cristóbal de las Casas, Mexico (limited coverage, abridged)",
                    "value": {
                      "place": {
                        "name": "San Cristóbal de las Casas, Chiapas, Mexico",
                        "lat": 16.73006,
                        "lon": -92.63825,
                        "precision": "city",
                        "country": "MX",
                        "state": null,
                        "state_name": "Chiapas",
                        "county": "San Cristobal De Casas"
                      },
                      "alternatives": [],
                      "coverage": "limited",
                      "hardiness_zone": {
                        "zone": "11a",
                        "system": "USDA-equivalent",
                        "source": "approximate — average coldest night over 10 years (Open-Meteo/ERA5)",
                        "avg_extreme_min_f": 40.8
                      },
                      "ecoregion": null,
                      "climate": {
                        "annual_precip_mm": 2132,
                        "annual_precip_in": 84,
                        "last_spring_frost": null,
                        "first_fall_frost": null,
                        "frost_free_days": null,
                        "frost_years": 0,
                        "frost_free_climate": null,
                        "elevation_m": 2118,
                        "years": 10,
                        "source": "Open-Meteo historical weather (ERA5 reanalysis, ~10 km grid)"
                      },
                      "soil": null,
                      "palette": {},
                      "avoid": [],
                      "observed_nearby": [
                        {
                          "name": "Tillandsia guatemalensis",
                          "scientific": "Tillandsia guatemalensis",
                          "records": 389,
                          "native_here": "unknown",
                          "invasive_here": false
                        }
                      ],
                      "notes": [
                        "At ~2118 m elevation, nights in valleys and basins are often several °C colder than this grid-based climate shows — treat the hardiness zone and frost data as a warm-side estimate and choose cold-tolerant plants where frost is possible.",
                        "EcoPlot's native-plant catalog covers the US and Canada only, so there is no curated palette here. observed_nearby lists the plants most recorded within ~10 km (GBIF) — a mix of natives, crops, weeds and garden escapes; their native status is unverified, so check before calling anything native."
                      ],
                      "attribution": [
                        "Place lookup: © OpenStreetMap contributors (ODbL), GeoNames (CC BY 4.0), US Census Bureau",
                        "Weather history: Open-Meteo.com (CC BY 4.0), ERA5",
                        "Plant records: GBIF.org"
                      ],
                      "cached": false
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "The place couldn't be found (`place_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "place_not_found",
                    "message": "Couldn't find \"Qwxzzy Nowhereville\". Try a city and state/country, a ZIP code, or an address."
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "description": "The place lookup services are unreachable (`geocoder_unavailable`). Retry shortly, or send `lat`/`lon`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/species": {
      "get": {
        "tags": [
          "Species"
        ],
        "operationId": "getSpecies",
        "summary": "A plant's profile, toxicity, bloom and reference photos",
        "description": "Look a plant up by common or scientific name, or both as\n`Common name (Scientific name)`. A scientific name is matched exactly;\na common name is matched as written, then loosely.\n\n**Reference photos**, best first:\n1. Candidates are gathered from EcoPlot's catalog and from\n   iNaturalist (the species' curated photos, then research-grade\n   observations annotated as flowering). Every photo is licence-checked:\n   only CC0 / public domain, CC BY and CC BY-SA pass, so all of them\n   allow commercial use. Each photo's `license` and `attribution` is\n   returned.\n2. A vision model rates each candidate as a render reference. The\n   whole plant in bloom, in true colour, ranks first; buds, frosted or\n   dormant plants and distant field shots are dropped. The first photo\n   is the best whole-plant (`view: habit`) shot in bloom, the second\n   the best flower close-up, then the rest by rating.\n3. Only if no usable photo exists: one AI-generated botanical\n   reference, marked `generated: true`.\n\nUse `include` to ask for less. Profiles and toxicity are generated once\nper species and then cached, so the first request for an uncommon\nplant can take a few seconds.\n",
        "parameters": [
          {
            "name": "name",
            "in": "query",
            "required": true,
            "description": "Common name, scientific name, or `Common name (Scientific name)`. 3–120 characters.",
            "schema": {
              "type": "string",
              "minLength": 3,
              "maxLength": 120
            },
            "examples": {
              "scientific": {
                "value": "Echinacea purpurea"
              },
              "common": {
                "value": "little bluestem"
              },
              "both": {
                "value": "Purple coneflower (Echinacea purpurea)"
              }
            }
          },
          {
            "name": "images",
            "in": "query",
            "required": false,
            "description": "How many reference photos to return (0–6).",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 6,
              "default": 4
            }
          },
          {
            "name": "include",
            "in": "query",
            "required": false,
            "description": "Comma-separated parts to return. Default all four.",
            "style": "form",
            "explode": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "profile",
                  "safety",
                  "bloom",
                  "images"
                ]
              }
            },
            "example": [
              "images",
              "bloom"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "The plant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Species"
                },
                "examples": {
                  "coneflower": {
                    "summary": "Echinacea purpurea",
                    "value": {
                      "name": "Eastern Purple Coneflower",
                      "scientific": "Echinacea purpurea",
                      "catalog": {
                        "native_states_us": [
                          "AL",
                          "AR",
                          "GA",
                          "IA",
                          "IL",
                          "IN",
                          "KS",
                          "KY",
                          "LA",
                          "MI",
                          "MO",
                          "MS",
                          "NC",
                          "OH",
                          "OK",
                          "TN",
                          "TX",
                          "VA",
                          "WI"
                        ],
                        "native_provinces_ca": [],
                        "invasive_us": false,
                        "management": null
                      },
                      "profile": {
                        "summary": "The Eastern Purple Coneflower (Echinacea purpurea) is a perennial herb known for its striking purple flowers and prominent central cone…",
                        "habitat": "Prairies, open woodlands",
                        "uses": "…",
                        "caution": null,
                        "caution_severity": "none"
                      },
                      "animal_safety": {
                        "worst": "safe",
                        "summary": "Listed as non-toxic to dogs, cats and horses.",
                        "animals": {
                          "dogs": {
                            "status": "safe",
                            "parts": null,
                            "source": "ASPCA"
                          },
                          "cats": {
                            "status": "safe",
                            "parts": null,
                            "source": "ASPCA"
                          },
                          "horses": {
                            "status": "safe",
                            "parts": null,
                            "source": "ASPCA"
                          },
                          "cattle": {
                            "status": "unknown",
                            "parts": null,
                            "source": null
                          },
                          "sheep_goats": {
                            "status": "unknown",
                            "parts": null,
                            "source": null
                          },
                          "poultry": {
                            "status": "unknown",
                            "parts": null,
                            "source": null
                          }
                        }
                      },
                      "bloom": {
                        "color": "#b05fa0",
                        "color_name": "purple",
                        "months": [
                          6,
                          7,
                          8
                        ],
                        "foliage": "#4f7a3a",
                        "height_m": 1
                      },
                      "images": [
                        {
                          "url": "https://inaturalist-open-data.s3.amazonaws.com/photos/29556621/large.jpg",
                          "source": "inaturalist",
                          "license": "CC BY",
                          "attribution": "(c) Sandy Wolkenberg, some rights reserved (CC BY)",
                          "generated": false,
                          "view": "habit",
                          "in_bloom": true
                        },
                        {
                          "url": "https://inaturalist-open-data.s3.amazonaws.com/photos/112531883/large.jpg",
                          "source": "inaturalist",
                          "license": "CC BY",
                          "attribution": "(c) James St. John, some rights reserved (CC BY)",
                          "generated": false,
                          "view": "flower",
                          "in_bloom": true
                        }
                      ]
                    }
                  },
                  "oreopanax": {
                    "summary": "A plant outside the catalog (iNaturalist photos)",
                    "value": {
                      "name": "Oreopanax xalapensis",
                      "scientific": "Oreopanax xalapensis",
                      "catalog": null,
                      "profile": {
                        "summary": "Oreopanax xalapensis is a tropical shrub or small tree found in cloud forests and moist montane regions…",
                        "habitat": "Montane cloud forest",
                        "uses": null,
                        "caution": null,
                        "caution_severity": "none"
                      },
                      "animal_safety": {
                        "worst": "unknown",
                        "summary": null,
                        "animals": {
                          "dogs": {
                            "status": "unknown",
                            "parts": null,
                            "source": null
                          },
                          "cats": {
                            "status": "unknown",
                            "parts": null,
                            "source": null
                          },
                          "horses": {
                            "status": "unknown",
                            "parts": null,
                            "source": null
                          },
                          "cattle": {
                            "status": "unknown",
                            "parts": null,
                            "source": null
                          },
                          "sheep_goats": {
                            "status": "unknown",
                            "parts": null,
                            "source": null
                          },
                          "poultry": {
                            "status": "unknown",
                            "parts": null,
                            "source": null
                          }
                        }
                      },
                      "bloom": null,
                      "images": [
                        {
                          "url": "https://inaturalist-open-data.s3.amazonaws.com/photos/168567270/large.jpg",
                          "source": "inaturalist",
                          "license": "CC BY",
                          "attribution": "(c) …, some rights reserved (CC BY)",
                          "generated": false,
                          "view": "habit",
                          "in_bloom": false
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No plant by that name (`species_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "species_not_found",
                    "message": "Couldn't find a plant called \"zzzz\". Try its scientific name."
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Your EcoPlot API key (`ek_live_…`)."
      },
      "BearerKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "The same API key, sent as `Authorization: Bearer ek_live_…`."
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Missing or invalid parameters (`bad_request`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "bad_request",
                "message": "Send a place (text) or lat and lon."
              }
            }
          }
        }
      },
      "Unauthorized": {
        "description": "No API key (`missing_key`), or not a valid one (`invalid_key`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "invalid_key",
                "message": "That API key isn't valid."
              }
            }
          }
        }
      },
      "Forbidden": {
        "description": "The key is disabled (`key_disabled`) or not allowed this endpoint (`forbidden`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Over the per-minute (`rate_limited`) or daily (`daily_limit`) limit.",
        "headers": {
          "Retry-After": {
            "description": "Seconds to wait before retrying.",
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "rate_limited",
                "message": "More than 60 requests in a minute.",
                "retry_after": 60
              }
            }
          }
        }
      },
      "Internal": {
        "description": "Something went wrong on our side (`internal`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "bad_request",
                  "missing_key",
                  "invalid_key",
                  "key_disabled",
                  "forbidden",
                  "not_found",
                  "place_not_found",
                  "species_not_found",
                  "rate_limited",
                  "daily_limit",
                  "geocoder_unavailable",
                  "unavailable",
                  "internal"
                ]
              },
              "message": {
                "type": "string",
                "description": "Human-readable; safe to show or log."
              },
              "retry_after": {
                "type": "integer",
                "description": "Seconds to wait (429 only)."
              },
              "detail": {
                "type": "string",
                "description": "Extra diagnostic detail (some 503s)."
              }
            }
          }
        }
      },
      "GrowthForm": {
        "type": "string",
        "enum": [
          "tree",
          "shrub",
          "grass",
          "forb",
          "vine"
        ],
        "description": "`grass` covers grasses, sedges and rushes; `forb` covers wildflowers, ferns and other herbaceous plants; `vine` covers climbing and trailing vines."
      },
      "SiteEcologyRequest": {
        "type": "object",
        "description": "Send `place`, or both `lat` and `lon`.",
        "properties": {
          "place": {
            "type": "string",
            "maxLength": 200,
            "description": "A city with its state or country, a ZIP or postcode, or a street address.",
            "examples": [
              "Ames, Iowa",
              "78704",
              "1600 Pennsylvania Ave NW, Washington, DC 20500",
              "Toronto"
            ]
          },
          "lat": {
            "type": "number",
            "minimum": -90,
            "maximum": 90
          },
          "lon": {
            "type": "number",
            "minimum": -180,
            "maximum": 180
          },
          "forms": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GrowthForm"
            },
            "description": "Only these growth forms in the palette. Default all five."
          },
          "per_form": {
            "type": "integer",
            "minimum": 1,
            "maximum": 15,
            "default": 8,
            "description": "Plants per growth form in the palette."
          }
        },
        "anyOf": [
          {
            "required": [
              "place"
            ]
          },
          {
            "required": [
              "lat",
              "lon"
            ]
          }
        ]
      },
      "Place": {
        "type": "object",
        "required": [
          "name",
          "lat",
          "lon",
          "precision",
          "country"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "The matched place, e.g. \"Ames, Story County, Iowa, United States\"."
          },
          "lat": {
            "type": "number"
          },
          "lon": {
            "type": "number"
          },
          "precision": {
            "type": "string",
            "enum": [
              "address",
              "postcode",
              "city",
              "region"
            ],
            "description": "How specific the match is. Soil at city or region precision is typical for the area, not a specific lot."
          },
          "country": {
            "type": [
              "string",
              "null"
            ],
            "description": "ISO 3166-1 alpha-2, e.g. US. Null if it couldn't be determined."
          },
          "state": {
            "type": [
              "string",
              "null"
            ],
            "description": "US state or Canadian province code (e.g. IA, ON). Null elsewhere."
          },
          "state_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "county": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "HardinessZone": {
        "type": "object",
        "required": [
          "zone",
          "system",
          "source"
        ],
        "properties": {
          "zone": {
            "type": "string",
            "description": "USDA zone, 1a–13b.",
            "examples": [
              "5b"
            ]
          },
          "system": {
            "type": "string",
            "enum": [
              "USDA",
              "USDA-equivalent"
            ],
            "description": "`USDA`: the official 2023 map (US, by ZIP). `USDA-equivalent`: computed from 10 years of weather — approximate."
          },
          "source": {
            "type": "string"
          },
          "avg_extreme_min_f": {
            "type": "number",
            "description": "Average coldest night (°F); computed zones only."
          }
        }
      },
      "Ecoregion": {
        "type": "object",
        "description": "US EPA ecoregions (US only).",
        "properties": {
          "level4": {
            "type": [
              "string",
              "null"
            ],
            "examples": [
              "Des Moines Lobe"
            ]
          },
          "level3": {
            "type": [
              "string",
              "null"
            ],
            "examples": [
              "Western Corn Belt Plains"
            ]
          },
          "level2": {
            "type": [
              "string",
              "null"
            ],
            "examples": [
              "Temperate Prairies"
            ]
          },
          "level1": {
            "type": [
              "string",
              "null"
            ],
            "examples": [
              "Great Plains"
            ]
          },
          "source": {
            "type": "string"
          }
        }
      },
      "Climate": {
        "type": "object",
        "description": "From 10 recent years of ERA5 reanalysis (~10 km grid). Normals fields may be absent if the record is incomplete.",
        "properties": {
          "annual_precip_mm": {
            "type": "number"
          },
          "annual_precip_in": {
            "type": "number"
          },
          "warmest_month": {
            "type": "object",
            "properties": {
              "month": {
                "type": "string",
                "examples": [
                  "Jul"
                ]
              },
              "avg_high_c": {
                "type": "number"
              },
              "avg_high_f": {
                "type": "number"
              }
            }
          },
          "coldest_month": {
            "type": "object",
            "properties": {
              "month": {
                "type": "string",
                "examples": [
                  "Jan"
                ]
              },
              "avg_low_c": {
                "type": "number"
              },
              "avg_low_f": {
                "type": "number"
              }
            }
          },
          "last_spring_frost": {
            "type": [
              "string",
              "null"
            ],
            "description": "Median date of the last frost (≤ 0 °C), e.g. \"Apr 19\". Null if frost is rare."
          },
          "first_fall_frost": {
            "type": [
              "string",
              "null"
            ],
            "description": "Median date of the first autumn frost."
          },
          "frost_free_days": {
            "type": [
              "integer",
              "null"
            ]
          },
          "frost_years": {
            "type": "integer",
            "description": "How many of the measured years had any frost."
          },
          "frost_free_climate": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "True if no frost was recorded; null when that can't be trusted (high elevation)."
          },
          "elevation_m": {
            "type": [
              "number",
              "null"
            ]
          },
          "years": {
            "type": [
              "integer",
              "null"
            ]
          },
          "source": {
            "type": "string"
          }
        }
      },
      "Soil": {
        "type": "object",
        "description": "USDA SSURGO soil over the top 30 cm of a ~100 m square at the point (US only).",
        "properties": {
          "texture": {
            "type": [
              "string",
              "null"
            ],
            "examples": [
              "Loam"
            ]
          },
          "ph": {
            "type": [
              "number",
              "null"
            ]
          },
          "organic_matter_pct": {
            "type": [
              "number",
              "null"
            ]
          },
          "drainage": {
            "type": [
              "string",
              "null"
            ],
            "examples": [
              "Well drained"
            ]
          },
          "sand_pct": {
            "type": [
              "number",
              "null"
            ]
          },
          "silt_pct": {
            "type": [
              "number",
              "null"
            ]
          },
          "clay_pct": {
            "type": [
              "number",
              "null"
            ]
          },
          "slope_pct": {
            "type": [
              "number",
              "null"
            ]
          },
          "water_holding_in_30cm": {
            "type": [
              "number",
              "null"
            ],
            "description": "Plant-available water in the top 30 cm, inches."
          },
          "soil_series": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Main named soils, largest first."
          },
          "depth_cm": {
            "type": "integer"
          },
          "source": {
            "type": "string"
          }
        }
      },
      "Bloom": {
        "type": "object",
        "description": "Typical ornamental facts. Grasses report their seedhead colour; plants without showy flowers have `months: []`.",
        "properties": {
          "color": {
            "type": "string",
            "description": "Dominant bloom colour, hex., examples: [\"#b05fa0\"]"
          },
          "color_name": {
            "type": "string",
            "examples": [
              "purple"
            ]
          },
          "months": {
            "type": "array",
            "items": {
              "type": "integer",
              "minimum": 1,
              "maximum": 12
            },
            "description": "Months usually in bloom (temperate US)."
          },
          "height_m": {
            "type": [
              "number",
              "null"
            ],
            "description": "Typical mature height, metres."
          }
        }
      },
      "PalettePlant": {
        "type": "object",
        "required": [
          "name",
          "scientific",
          "native_here",
          "observed_nearby"
        ],
        "properties": {
          "name": {
            "type": "string",
            "examples": [
              "Butterflyweed"
            ]
          },
          "scientific": {
            "type": [
              "string",
              "null"
            ],
            "examples": [
              "Asclepias tuberosa"
            ]
          },
          "native_here": {
            "oneOf": [
              {
                "type": "boolean"
              },
              {
                "type": "string",
                "const": "unknown"
              }
            ]
          },
          "observed_nearby": {
            "type": "boolean",
            "description": "Recorded within ~10 km (GBIF)."
          },
          "bloom": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Bloom"
              },
              {
                "type": "null"
              }
            ]
          },
          "image_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "One catalog photo licensed for commercial use (CC0, CC BY, CC BY-SA), or null; use /v1/species for rated reference photos."
          }
        }
      },
      "SiteEcology": {
        "type": "object",
        "required": [
          "place",
          "alternatives",
          "coverage",
          "palette",
          "avoid",
          "observed_nearby",
          "notes",
          "attribution",
          "cached"
        ],
        "properties": {
          "place": {
            "$ref": "#/components/schemas/Place"
          },
          "alternatives": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Other places the text could mean (up to 3)."
          },
          "coverage": {
            "type": "string",
            "enum": [
              "full",
              "limited"
            ],
            "description": "`full`: a native palette from EcoPlot's catalog (US and Canada). `limited`: no palette — see `observed_nearby` and `notes`."
          },
          "hardiness_zone": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/HardinessZone"
              },
              {
                "type": "null"
              }
            ]
          },
          "ecoregion": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Ecoregion"
              },
              {
                "type": "null"
              }
            ]
          },
          "climate": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Climate"
              },
              {
                "type": "null"
              }
            ]
          },
          "soil": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Soil"
              },
              {
                "type": "null"
              }
            ]
          },
          "palette": {
            "type": "object",
            "description": "Native plants by growth form, best first. Empty object when coverage is limited.",
            "properties": {
              "tree": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/PalettePlant"
                }
              },
              "shrub": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/PalettePlant"
                }
              },
              "grass": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/PalettePlant"
                }
              },
              "forb": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/PalettePlant"
                }
              },
              "vine": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/PalettePlant"
                }
              }
            }
          },
          "avoid": {
            "type": "array",
            "description": "Invasive plants listed for this state or province (up to 15), those recorded nearby first.",
            "items": {
              "type": "object",
              "required": [
                "name",
                "scientific",
                "observed_nearby",
                "why"
              ],
              "properties": {
                "name": {
                  "type": "string"
                },
                "scientific": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "observed_nearby": {
                  "type": "boolean"
                },
                "why": {
                  "type": "string",
                  "description": "One line of management advice."
                }
              }
            }
          },
          "observed_nearby": {
            "type": "array",
            "description": "The plants most recorded within ~10 km (GBIF), up to 20 — natives, crops, weeds and garden escapes alike.",
            "items": {
              "type": "object",
              "required": [
                "name",
                "scientific",
                "records",
                "native_here",
                "invasive_here"
              ],
              "properties": {
                "name": {
                  "type": "string"
                },
                "scientific": {
                  "type": "string"
                },
                "records": {
                  "type": "integer"
                },
                "native_here": {
                  "oneOf": [
                    {
                      "type": "boolean"
                    },
                    {
                      "type": "string",
                      "const": "unknown"
                    }
                  ]
                },
                "invasive_here": {
                  "type": "boolean"
                }
              }
            }
          },
          "notes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Plain-language caveats — what's missing, approximate, or unavailable right now. Show or heed these."
          },
          "attribution": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Credits for the data sources used in this answer."
          },
          "cached": {
            "type": "boolean",
            "description": "True if served from the 30-day area cache."
          }
        }
      },
      "AnimalStatus": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "safe",
              "mild",
              "toxic",
              "severe",
              "unknown"
            ],
            "description": "`safe` only when a reference lists it as non-toxic; `unknown` when references are silent."
          },
          "parts": {
            "type": [
              "string",
              "null"
            ],
            "description": "Toxic parts, if any."
          },
          "source": {
            "type": [
              "string",
              "null"
            ],
            "description": "The reference relied on, e.g. ASPCA; Cornell CALS."
          }
        }
      },
      "Image": {
        "type": "object",
        "required": [
          "url",
          "source",
          "generated"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri"
          },
          "source": {
            "type": "string",
            "enum": [
              "ecoplot",
              "inaturalist",
              "generated"
            ]
          },
          "license": {
            "type": [
              "string",
              "null"
            ],
            "description": "For iNaturalist photos: CC0, CC BY or CC BY-SA."
          },
          "attribution": {
            "type": [
              "string",
              "null"
            ],
            "description": "The credit to show with the photo."
          },
          "generated": {
            "type": "boolean",
            "description": "True for an AI-generated reference (used only when no photo exists)."
          },
          "view": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "habit",
              "flower",
              "foliage",
              "fruit",
              "other",
              null
            ],
            "description": "What the photo shows: `habit` is the whole plant or a planting (its overall shape and size); `flower` a close-up of open flowers. Null if the photo wasn't rated."
          },
          "in_bloom": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Open flowers visible (for grasses, seed heads or plumes)."
          }
        }
      },
      "Species": {
        "type": "object",
        "required": [
          "name",
          "scientific",
          "catalog",
          "images"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "scientific": {
            "type": [
              "string",
              "null"
            ]
          },
          "catalog": {
            "description": "EcoPlot catalog entry, if the plant is in it.",
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "native_states_us": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "US state codes where native."
                  },
                  "native_provinces_ca": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "invasive_us": {
                    "type": "boolean"
                  },
                  "management": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Control advice (invasives only)."
                  }
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "profile": {
            "description": "Requires `include=profile`.",
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "summary": {
                    "type": "string"
                  },
                  "habitat": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "uses": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Documented human and natural-resource uses."
                  },
                  "caution": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "description": "Toxicity, look-alikes, legal protection or overharvest risk."
                  },
                  "caution_severity": {
                    "type": "string",
                    "enum": [
                      "none",
                      "caution",
                      "danger"
                    ]
                  }
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "animal_safety": {
            "description": "Requires `include=safety`.",
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "worst": {
                    "type": "string",
                    "enum": [
                      "safe",
                      "mild",
                      "toxic",
                      "severe",
                      "unknown"
                    ]
                  },
                  "summary": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "animals": {
                    "type": "object",
                    "properties": {
                      "dogs": {
                        "$ref": "#/components/schemas/AnimalStatus"
                      },
                      "cats": {
                        "$ref": "#/components/schemas/AnimalStatus"
                      },
                      "horses": {
                        "$ref": "#/components/schemas/AnimalStatus"
                      },
                      "cattle": {
                        "$ref": "#/components/schemas/AnimalStatus"
                      },
                      "sheep_goats": {
                        "$ref": "#/components/schemas/AnimalStatus"
                      },
                      "poultry": {
                        "$ref": "#/components/schemas/AnimalStatus"
                      }
                    }
                  }
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "bloom": {
            "description": "Requires `include=bloom`; catalog plants only.",
            "oneOf": [
              {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/Bloom"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "foliage": {
                        "type": "string",
                        "description": "Summer foliage colour, hex."
                      }
                    }
                  }
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "images": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Image"
            },
            "description": "Reference photos, best first (`images` of them). Requires `include=images`."
          }
        }
      }
    }
  }
}
