Pet Recognition API Online
Find out if a photo shows a dog, and which breed. POST one image (JPEG, PNG, WebP, BMP or TIFF, max 8 MB, at least 200 pixels on the shorter side) as a JSON body with image_url or image_base64, as a multipart/form-data upload in the field "image", or as the raw bytes with an image/* Content-Type. A dog detector checks the photo first: no dog means 404 no_dog_detected. Then two breed models give up to 3 breeds from a list of 60 common breeds, with scores. Dogs only: cats and other animals are not recognised. The API recognises the breed, not the individual animal. Typical uses: pet apps, smart pet doors, and Home Assistant or other home-automation platforms. The result is a classification with a score, not a guarantee: your system sets the threshold and decides what to do. Images are processed in memory and never stored.
POST https://nakordoni.eu/api/v2/data/pet-recognition
— quota class: pet · Own pet-recognition quota: 20/day on the free Explorer plan (same as plate recognition), 1,000 Student, 2,000 Starter, 10,000 Pro, 50,000 Pro MAX; 10/day for Personal & hobby projects.
| Parameter | Description |
|---|---|
image_url | (JSON body) Public http(s) URL of the image. Max 8 MB, max 3 redirects, 10 s download limit. |
image_base64 | (JSON body) The image as base64 (a data:image/...;base64, prefix is allowed). Send image_url or image_base64, not both. |
Response fields — inside the data object of the envelope. [] marks a list, so data.items[].name is the name field of each element. A field is null, absent or an empty list when we hold no value for it — never a placeholder.
| Field | Description |
|---|---|
data.success | true when a dog was found; data.message says the result in words. |
data.processing_time | Time spent on the request in milliseconds (download, dog detection and breed recognition). |
data.species | Always "dog" (the only species we recognise). |
data.dog_score | Confidence 0-1 of the dog detector. |
data.breed | {id, name, score}: the breed, set only when both breed models agree on it; null when they do not agree. Use data.breeds then. |
data.breeds[] | Up to 3 breeds {id, name, score}, most likely first. id is a stable slug (for example labrador). score is the main model score 0-1; it is relative, often low (0.05-0.2) even for a correct breed, so compare breeds by order, not by a fixed score. Empty when the dog matches none of the 60 breeds. |
data.models_agree | true when both breed models chose the same first breed (then data.breed is set). |
error.code | 400: image_required, bad_json, bad_base64, one_image_only, bad_image_url, image_url_not_allowed, image_url_fetch_failed, image_url_timeout, invalid_image, image_too_small, unsupported_image_type, unsupported_content_type, upload_failed. 404: no_dog_detected. 413: payload_too_large. 500: engine_error. 503: engine_unavailable or engine_busy, with a Retry-After header and error.retry_after (seconds); when the engine is already paused before your call starts, the 503 engine_unavailable is not counted against your quota. |
curl -X POST "https://nakordoni.eu/api/v2/data/pet-recognition" \
-H "Authorization: Bearer NKD-DEV-XXXX-XXXX-XXXX" \
-H "Content-Type: application/json" \
-d '{
"image_url": "https://upload.wikimedia.org/wikipedia/commons/2/26/YellowLabradorLooking_new.jpg"
}'
Dog detection and dog breed recognition from a photo
The Pet Recognition API tells you if a photo shows a dog and which breed it most likely is. A dog detector checks the photo first. Then two independently trained breed models give up to 3 breeds from a list of 60 common breeds. The breed field is set only when both models agree. The API recognises dogs only, not cats or other animals. It recognises the breed, not the individual animal, so it cannot tell your dog from a neighbour's dog of the same breed. The same engine suggests breeds in our GassiTrail dog-walking app.
Version v3: dogs and cats
Version v3 (POST /api/v3/data/pet-recognition) recognises dogs and cats. For a dog it works like v2. For a cat, a breed model gives 3 breeds from a list of 12 pedigree breeds, with scores. The breed field is set when the first breed has a score of 0.5 or more; otherwise breed is null and breed_unknown_reason is "not_confident". Mixed-breed cats usually return breed null. v2 does not change and recognises dogs only.
The 12 cat breeds: Abyssinian, Bengal, Birman, Bombay, British Shorthair, Egyptian Mau, Maine Coon, Persian, Ragdoll, Russian Blue, Siamese, Sphynx.
Cat breed model trained on the Oxford-IIIT Pet Dataset, Parkhi et al., CC BY-SA 4.0.
Use cases
- Pet apps: fill in the breed of a dog profile from a photo, or offer the top 3 breeds as a picker.
- Smart pet doors and feeders: check if the animal in front of the camera is a dog before your own logic acts.
- Home Assistant and other home-automation platforms: send a camera snapshot and use the JSON answer in an automation.
Example: Home Assistant
This example takes a snapshot when the pet-door motion sensor triggers, sends it to the API and sends a notification when a dog is detected. It does not open the door: add your own door logic and keep its safe default.
# configuration.yaml (secrets.yaml: nakordoni_api_key: "NKD-DEV-...")
# /config/www must be in homeassistant: allowlist_external_dirs
shell_command:
pet_check: >-
curl -s -m 15 -X POST
-H "Authorization: Bearer {{ key }}"
-F "image=@/config/www/pet_door.jpg"
https://nakordoni.eu/api/v2/data/pet-recognition
# automations.yaml
- alias: "Pet door camera: dog check"
triggers:
- trigger: state
entity_id: binary_sensor.pet_door_motion
to: "on"
actions:
- action: camera.snapshot
target:
entity_id: camera.pet_door
data:
filename: /config/www/pet_door.jpg
- action: shell_command.pet_check
data:
key: !secret nakordoni_api_key
response_variable: pet
- variables:
r: "{{ pet.stdout | from_json if pet.returncode == 0 and pet.stdout.startswith('{') else {} }}"
# No answer, an error or a 503 (Retry-After): do nothing, keep the door's own default.
- condition: template
value_template: "{{ r.get('ok', false) and r.data.dog_score >= 0.8 }}"
- action: notify.notify
data:
message: >-
Dog at the pet door{{ ': ' ~ r.data.breed.name if r.data.breed else '' }}
(detector score {{ r.data.dog_score }})Updated