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.
See our documentation for the full reference.
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
See the JSON response example.
- Python example - synchronous
- Python example - asynchronous
- Java example
- JavaScript example
- node.js example
- PHP example
- Rust example
Don't know how to code? Try the online demo.