Package: kindwise-api-client
Kindwise sdk for pythonPython SDK toolkit for integrating Kindwise API into your application. This Python SDK provides a convenient way to
interact with the Kindwise API for plant, insect, and mushroom identification. The SDK is organized into different
modules, each corresponding to a specific domain (plant,insect,mushroom). You can always use our
API without our SDK, the documentation can be found on the following links:plantinsectmushroomSetupInstallpipinstallkindwiseAPI keyThe API key serves to identify your account and is required to make requests to the API. Get API key atadmin.kindwise.com.Quick StartTo use Kindwise API, an active API key is needed. See the sectionaboveon how to get an API key.fromkindwise.plantimportPlantApifromkindwise.modelsimportPlantIdentification,UsageInfo# initialize plant.id api# "PLANT_API_KEY" environment variable can be set instead of specifying api_keyapi=PlantApi(api_key='your_api_key')# get usage informationusage:UsageInfo=api.usage_info()# identify plant by imagelatitude_longitude=(49.20340,16.57318)# pass the image as a pathimage_path='path/to/plant_image.jpg'# make identificationidentification:PlantIdentification=api.identify(image_path,latitude_longitude=latitude_longitude)# get identification by a token with changed views# this method can be used to modify additional information in identification or to get identification from database# also works with identification.custom_ididentification_with_different_views:PlantIdentification=api.get_identification(identification.access_token)# delete identificationapi.delete_identification(identification)# also works with identification.access_token or identification.custom_idStructureSDK supports the following Kindwise systems:plant.idinsect.idmushroom.idEach system has its class, which is used to make requests to the API. Each class has the following methods:methoddescriptionreturn typeplantinsectmushroomidentifycreate new identificationIdentification:white_check_mark::white_check_mark::white_check_mark:get_identificationget identification by tokenIdentification:white_check_mark::white_check_mark::white_check_mark:delete_identificationdelete identification by tokenboolean:white_check_mark::white_check_mark::white_check_mark:usage_infoget api key usage informationUsageInfo:white_check_mark::white_check_mark::white_check_mark:feedbacksend feedback for identificationboolean:white_check_mark::white_check_mark::white_check_mark:health_assessmentcreate health assessment identificationHealthAssessment:white_check_mark::x::x:get_health_assessmentget health assessment identificationHealthAssessment:white_check_mark::x::x:delete_health_assessmentdelete health assessmentboolean:white_check_mark::x::x:available_detailsdetails which can be used to specify additional information foridentifydict:white_check_mark::white_check_mark::white_check_mark:available_disease_detailsdetails which can be used to specify additional information forhealth_assessmentdict:white_check_mark::x::x:Datetime objects are created by methoddatetime.fromtimestamp(timestamp). This means that datetime objects are in
local timezone.Documentationavailable_detailsReturns details which can be used to specify additional information foridentifymethod. `fromkindwiseimportPlantApiapi=PlantApi()available_details=api.available_details()identifyCreates a new identification. In one identification, you can include up to 5 images.importbase64fromdatetimeimportdatetimefromkindwiseimportPlantApi,PlantIdentification,ClassificationLevelapi=PlantApi(api_key='your_api_key')# this creates one identification composed of 5 images(not 5 different identifications)## as input image is accepted path to an image(str / pathlib.Path), base64 encoded stream(bytes/string), stream(bytes/string),# or file object(supports read,seek and mode methods)# or PIL.Image.Image object# or list of imagesimages=['path/to/image1.jpg','path/to/image2.jpg','path/to/image3.jpg','path/to/image4.jpg','path/to/image5.jpg']# details included in identificationdetails=['common_names','taxonomy','image']# disease details included in health identification(only used if health=True)# disease_details parameter is only available for plant.iddisease_details=['local_name','description','treatment','cause']# specify up to 3 languageslanguage=['en','cs']# default for similar_images is Truesimilar_images=True# where was an image takenlatitude_longitude=(49.20340,16.57318)# include health assessment in your identification by specifying health='all',# also use health='only' to get HealthAssessment(health assessment only)# health assessment is only available for plant.idhealth='all'# custom id is used to identify identification in your system, but can be replaced with access_tokencustom_id=123# when was an image taken, datetime can be specified as a datetime object, timestamp, or string in ISO formatdate_time=datetime.now()# default image size is 1500px, can be turned off by setting max_image_size to None# be aware that our API has limit 25Mpx(e.g. 5000px x 5000px)max_image_size=1500# specify into what depth should be the plant classified# choose from ClassificationLevel.SPECIES, ClassificationLevel.GENUS, ClassificationLevel.ALL# default is ClassificationLevel.SPECIESclassification_level=ClassificationLevel.SPECIES# in case of need to merge results for different taxon levels yourself, set classification_raw=True# be aware that the result will be in type kindwise.models.RawPlantIdentificationclassification_raw=False# if our api will be ahead of this sdk and you do not want to wait for update,# specify extra_get_params or extra_post_paramsextra_get_params=None# defaultextra_post_params=None# defaultidentification:PlantIdentification=api.identify(images,details=details,disease_details=disease_details,language=language,similar_images=similar_images,latitude_longitude=latitude_longitude,health=health,custom_id=custom_id,date_time=date_time,max_image_size=max_image_size,classification_level=classification_level,classification_raw=classification_raw,extra_get_params=extra_get_params,extra_post_params=extra_post_params,)# identification created from streamwithopen('path/to/image.jpg','rb')asimage:identification_from_stream:PlantIdentification=api.identify(image.read())# identification created from file objectwithopen('path/to/image.jpg','rb')asimage:identification_from_file:PlantIdentification=api.identify(image)# identification created from base64 encoded imagewithopen('path/to/image.jpg','rb')asimage:image_in_base64=base64.b64encode(image.read())identification_from_base64:PlantIdentification=api.identify(image)When you don't want to wait until the identification is finished, you can specifyasynchronous=Trueand
getaccess_tokenorcustom_idif specified and retrieve the answer later.fromkindwiseimportPlantApi,PlantIdentificationapi=PlantApi(api_key='your_api_key')image='path/to/image.jpg'identification:PlantIdentification=api.identify(image,asynchronous=True)# now do something else# ...# and later get identification by access_token or custom_ididentification:PlantIdentification=api.get_identification(identification.access_token,details=['common_names'])get_identificationGet identification by token. You can specify which details you want to get. We store your identifications for 6 months.fromkindwiseimportPlantApi,PlantIdentificationapi=PlantApi(api_key='your_api_key')access_token='identification_access_token'# details included in identification, can be different from used in identification createdetails=['common_names','taxonomy','image']# language can also differ from used in identification createlanguage='de'identification:PlantIdentification=api.get_identification(access_token,details=details,language=language)delete_identificationDeletes identification from our database. You can specify identification by access_token or custom_id.fromkindwiseimportPlantApiapi=PlantApi(api_key='your_api_key')custom_id=123# also works with access_token or Identification objectapi.delete_identification(custom_id)usage_infoGives you information about your api key usage.fromkindwiseimportPlantApi,UsageInfoapi=PlantApi(api_key='your_api_key')usage_info:UsageInfo=api.usage_info()feedbackSend feedback for identification. You can specify a comment(string) or rating(int) in feedback. At least one of comment
and rating must be specified. You can specify identification by access_token or custom_id.fromkindwiseimportPlantApiapi=PlantApi(api_key='your_api_key')custom_id=123# also works with access_token or Identification objectapi.feedback(custom_id,comment='comment',rating=5)available_disease_detailsReturns details which can be used to specify additional information forhealth_assessmentmethod. Only available for
plant.id.fromkindwiseimportPlantApiapi=PlantApi()available_disease_details=api.available_disease_details()health_assessmentReturns only health assessment for identification. Health assessment is only available for plant.id.health_assessmentmethod is similar toidentifymethod, but it returns only health assessment. Details differs for each system.fromdatetimeimportdatetimefromkindwiseimportPlantApi,HealthAssessmentapi=PlantApi(api_key='your_api_key')# the same as in identify methodimages=['path/to/image1.jpg','path/to/image2.jpg','path/to/image3.jpg','path/to/image4.jpg','path/to/image5.jpg']# details included in identificationdetails=['local_name','description','treatment','cause','image']# specify up to 3 languageslanguage=['en','cs']# default for similar_images is Truesimilar_images=True# where was an image takenlatitude_longitude=(49.20340,16.57318)# custom id is used to identify identification in your system, but can be replaced with access_tokencustom_id=123# list of suggested diseases also contains general diseases such as "Abiotic", default is Falsefull_disease_list=True# when was an image taken, datetime can be specified as a datetime object, timestamp, or string in ISO formatdate_time=datetime.now()# default image size is 1500px, can be turned off by setting max_image_size to None# be aware that our API has limit 25Mpx(e.g. 5000px x 5000px)max_image_size=1500# if our api will be ahead of this sdk and you do not want to wait for update,# specify extra_get_params or extra_post_paramsextra_get_params=None# defaultextra_post_params=None# defaultidentification:HealthAssessment=api.health_assessment(images,details=details,language=language,similar_images=similar_images,latitude_longitude=latitude_longitude,custom_id=custom_id,full_disease_list=full_disease_list,date_time=date_time,max_image_size=max_image_size,)When you don't want to wait until the identification is finished, you can specifyasynchronous=Truesimilar
toidentifymethod.get_health_assessmentGet a health assessment for identification. You can specify which details you want to get. We store your identifications
for 6 months.fromkindwiseimportPlantApi,HealthAssessmentapi=PlantApi(api_key='your_api_key')access_token='identification_access_token'# details included in identification can be different from those used in identification creationdetails=['classification','local_name']# language can also differ from what is used in identification creationlanguage='de'full_disease_list=Falseidentification:HealthAssessment=api.get_health_assessment(access_token,details=details,language=language,full_disease_list=full_disease_list)delete_health_assessmentDelete health assessment for identification.fromkindwiseimportPlantApiapi=PlantApi(api_key='your_api_key')custom_id=123# also works with access_token or HealthAssessment objectapi.delete_health_assessment(custom_id)