/Plant-id-API

Example client's code for work with Plant.id identification API in various languages

Primary LanguagePython

Plant.id offers a plant identification service based on machine learning. Once you obtain the API key, you can use these client's code to speed-up the development of your implementation.

Plant.id API v2

Documentation

See our documentation for the full reference.

Simple Python example

import base64
import requests

# encode image to base64
with open("unknown_plant.jpg", "rb") as file:
    images = [base64.b64encode(file.read()).decode("ascii")]

your_api_key = "fd3slj47dj... -- ask for one: https://web.plant.id/api-access-request/ --"
json_data = {
    "images": images,
    "modifiers": ["similar_images"],
    "plant_details": ["common_names", "url", "wiki_description", "taxonomy"]
}

response = requests.post(
    "https://api.plant.id/v2/identify",
    json=json_data,
    headers={
        "Content-Type": "application/json",
        "Api-Key": your_api_key
    }).json()

for suggestion in response["suggestions"]:
    print(suggestion["plant_name"])    # Taraxacum officinale
    print(suggestion["plant_details"]["common_names"])    # ["Dandelion"]
    print(suggestion["plant_details"]["url"])    # https://en.wikipedia.org/wiki/Taraxacum_officinale

More examples

Don't know how to code? Try the online demo.