Plant identification API documentation
Published · Updated · Markdown
How do I identify a plant with the API?
- Sign in to the dashboard with GitHub or Google and create an API key. It starts with
genus_and is shown once. - Shrink the photo to 512 pixels on its shorter side and encode it as JPEG.
- POST it as the request body to
https://api.genusapi.com/v1/plants/identify, with the key in theAuthorizationheader andlatandlonin the query if you know where it was taken. - Read
results: the matches, most likely first, each with an iNaturalist taxon ID, a scientific name and a probability.
curl -X POST "https://api.genusapi.com/v1/plants/identify?lat=-27.51&lon=153.08&top=5" \
-H "Authorization: Bearer $GENUS_KEY" \
-H "Content-Type: image/jpeg" \
--data-binary @photo.jpg
The OpenAPI spec is at /openapi.json, and this page is also Markdown.
Authentication
Send your key as a bearer token on every call:
Authorization: Bearer genus_...
Keep the key on your server. Anyone can pull a key out of an app's binary or a web page's source, and calls on it are charged to you. Your app sends the photo to your server, and your server calls the API. You can revoke a key in the dashboard at any time, and it stops working within a minute.
Keys belong to your team, not to the person who made them, so they keep working when someone leaves. Give each key a daily credit limit in the dashboard: past it, paid calls on that key are refused until midnight UTC, so a leaked key uses at most its limit. We store only a SHA-256 hash of each key.
The identify call
POST https://api.genusapi.com/v1/plants/identify
| Query parameter | Type | What it does |
|---|---|---|
lat |
number, −90 to 90 | Where the photo was taken, in decimal degrees. Send it with lon. |
lon |
number, −180 to 180 | Send it with lat. |
top |
whole number, 1 to 20 | How many matches to return. 5 if you leave it out. |
The body is the photo itself, as raw bytes: JPEG, PNG or WebP, at most 6 MB. The API reads the type from the bytes, so the Content-Type header is optional. Photos taken on a phone come upright: the API applies the EXIF orientation.
Photo size
512 pixels on the shorter side gives the same answers as the full-size photo. The model looks at a 224-pixel square from the middle of the photo, so a bigger upload only adds time. Below 512 pixels accuracy drops: in our tests, 256 pixels cost about 4 points of first-match accuracy.
Location
With lat and lon, plants with research-grade iNaturalist records near that spot rank higher, and plants never recorded nearby rank lower. On our test photos that took the first match from 84.7% right to 92.6%. Two decimal places, about a kilometre, is enough. Read the location from the photo's EXIF data or from the device when the photo is taken.
The response
{
"request_id": "6f1c0e5a-2b7d-4c1e-9a43-0c5d1f7e8b21",
"model": "all-full-world-vits14-2026-11-22",
"location_used": true,
"results": [
{ "taxon_id": 476098, "name": "Tritonia laxifolia", "score": 0.95498 },
{ "taxon_id": 565962, "name": "Tritonia securigera", "score": 0.03669 },
{ "taxon_id": 595736, "name": "Tritonia dubia", "score": 0.00679 }
],
"credits_charged": 0,
"credits_left": 25000,
"free_calls_left": 499,
"ms": 41
}
| Field | What it is |
|---|---|
request_id |
This call's ID. Quote it if you contact us about a call. |
model |
The model that answered. It changes when we ship a new one. |
location_used |
Whether lat and lon were applied. |
results |
The matches, most likely first. |
results[].taxon_id |
The plant's iNaturalist taxon ID. Look up common names, photos and range with https://api.inaturalist.org/v1/taxa/{taxon_id}. |
results[].name |
The scientific name. |
results[].score |
The probability that this is the plant, from 0 to 1. Scores across all 60,902 species add up to 1, so the matches returned add up to 1 or a little less. |
credits_charged |
Credits this call took: 0 for a free call, 1 for a paid one. |
credits_left |
Your credits after this call, in whole credits. |
free_calls_left |
Free calls left on your account. Every new account gets 500, once. |
ms |
How long the identification took, in milliseconds. |
A low top score means the photo is hard to call. Show several matches, or ask the user for another photo of a different part of the plant.
Errors
Every error is JSON with a code to branch on and a message to act on:
{ "error": "no_credit", "message": "the free calls are used and there are no credits left; buy credits in the dashboard" }
| Status | error |
What to do |
|---|---|---|
| 400 | bad_location |
Send lat and lon together, within range. |
| 400 | bad_top |
Send top as a whole number from 1 to 20. |
| 400 | bad_photo |
The upload was cut short. Send it again. |
| 401 | invalid_key |
The key is wrong or revoked. |
| 402 | no_credit |
The free calls are used and there are no credits left. Buy credits in the dashboard. |
| 402 | key_limit |
This key reached its daily credit limit. Raise it in the dashboard, or wait for midnight UTC. |
| 403 | account_suspended |
Contact us. |
| 404 | not_found |
No such endpoint. Plants are POST /v1/plants/identify. |
| 413 | photo_too_large |
Shrink the photo to under 6 MB; 512 pixels is plenty. |
| 415 | unsupported_photo |
Send JPEG, PNG or WebP bytes as the body. |
| 429 | rate_limited |
Over your account's rate limit. Wait the seconds in Retry-After (also retry_after_seconds in the body) and send it again. |
| 500 | internal |
Our fault, not charged. Send it again. |
| 503 | busy |
At capacity, not charged. Send it again after the seconds in Retry-After. |
Timeouts and retries
Give each call at least 60 seconds before your HTTP client gives up. At a burst of traffic, a call waits in line for up to 45 seconds for capacity, then gets its answer. A call still waiting after 45 seconds is answered 503 busy with a Retry-After header: send it again after that many seconds. Retry a 500 once. Neither costs anything, and a call your client abandons before the answer isn't charged either.
Limits and billing
- Rate: 1,000 calls a minute per account, shared by all its keys, in bursts of up to 2,000; 120 a minute until the account has bought credit. Every answer has
RateLimit-Limit,RateLimit-RemainingandRateLimit-Reset(seconds until the full limit is back) headers, and a429addsRetry-After. For a higher limit, email [email protected]. - Free calls: 500 per account, once.
- Credit limit: optional, per key per day, in credits, set in the dashboard. Free calls don't count toward it.
- Paid calls: 1 credit each, the same for every call. Credits come in packs, as of November 2026: 5,000 credits for $25 ($5 per 1,000), 25,000 credits for $100 ($4 per 1,000), 100,000 credits for $300 ($3 per 1,000), 200,000 credits for $500 ($2.50 per 1,000), 1,000,000 credits for $2,000 ($2 per 1,000), 10,000,000 credits for $10,000 ($1 per 1,000). See pricing.
- Charging: a call is charged only when it returns matches. Errors cost nothing.
- Credits: each pack, bonus included, is valid for 12 months from the date of purchase. Paid calls spend the credits that expire first. Credits are not refundable; see the credit and refund policy.
Code
Each example sends one JPEG with a location and prints the top match.
Swift
import Foundation
struct Match: Decodable {
let taxonId: Int
let name: String
let score: Double
}
struct Identification: Decodable {
let requestId: String
let locationUsed: Bool
let results: [Match]
}
struct PlantIDError: Error {
let status: Int
let body: String
}
func identify(jpeg: Data, latitude: Double?, longitude: Double?, key: String) async throws -> Identification {
var components = URLComponents(string: "https://api.genusapi.com/v1/plants/identify")!
var query = [URLQueryItem(name: "top", value: "5")]
if let latitude, let longitude {
query.append(URLQueryItem(name: "lat", value: String(latitude)))
query.append(URLQueryItem(name: "lon", value: String(longitude)))
}
components.queryItems = query
var request = URLRequest(url: components.url!)
request.httpMethod = "POST"
request.setValue("Bearer \(key)", forHTTPHeaderField: "Authorization")
request.setValue("image/jpeg", forHTTPHeaderField: "Content-Type")
request.timeoutInterval = 60
let (data, response) = try await URLSession.shared.upload(for: request, from: jpeg)
let status = (response as? HTTPURLResponse)?.statusCode ?? 0
guard status == 200 else {
throw PlantIDError(status: status, body: String(decoding: data, as: UTF8.self))
}
let decoder = JSONDecoder()
decoder.keyDecodingStrategy = .convertFromSnakeCase
return try decoder.decode(Identification.self, from: data)
}
To get the JPEG from a UIImage at 512 pixels on the shorter side:
import UIKit
func uploadJPEG(_ image: UIImage, side: CGFloat = 512) -> Data? {
let scale = side / min(image.size.width, image.size.height)
guard scale < 1 else { return image.jpegData(compressionQuality: 0.9) }
let size = CGSize(width: image.size.width * scale, height: image.size.height * scale)
let format = UIGraphicsImageRendererFormat()
format.scale = 1
let resized = UIGraphicsImageRenderer(size: size, format: format).image { _ in
image.draw(in: CGRect(origin: .zero, size: size))
}
return resized.jpegData(compressionQuality: 0.9)
}
Kotlin
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody
import java.util.concurrent.TimeUnit
import org.json.JSONObject
val client = OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.build()
fun identify(jpeg: ByteArray, lat: Double?, lon: Double?, key: String): JSONObject {
val url = "https://api.genusapi.com/v1/plants/identify".toHttpUrl().newBuilder()
.addQueryParameter("top", "5")
.apply { if (lat != null && lon != null) { addQueryParameter("lat", "$lat"); addQueryParameter("lon", "$lon") } }
.build()
val request = Request.Builder()
.url(url)
.header("Authorization", "Bearer $key")
.post(jpeg.toRequestBody("image/jpeg".toMediaType()))
.build()
client.newCall(request).execute().use { response ->
val body = response.body!!.string()
check(response.isSuccessful) { "${response.code}: $body" }
return JSONObject(body)
}
}
// identify(bytes, -27.51, 153.08, key).getJSONArray("results").getJSONObject(0).getString("name")
JavaScript (Node 18+)
import { readFile } from "node:fs/promises";
async function identify(path, { lat, lon, top = 5 } = {}) {
const query = new URLSearchParams({ top });
if (lat != null && lon != null) { query.set("lat", lat); query.set("lon", lon); }
const res = await fetch(`https://api.genusapi.com/v1/plants/identify?${query}`, {
method: "POST",
headers: { Authorization: `Bearer ${process.env.GENUS_KEY}`, "Content-Type": "image/jpeg" },
body: await readFile(path),
signal: AbortSignal.timeout(60_000),
});
const body = await res.json();
if (!res.ok) throw new Error(`${res.status} ${body.error}: ${body.message}`);
return body;
}
const { results } = await identify("photo.jpg", { lat: -27.51, lon: 153.08 });
console.log(results[0].name, results[0].score);
Python
import os
import requests
def identify(path, lat=None, lon=None, top=5):
params = {"top": top}
if lat is not None and lon is not None:
params.update(lat=lat, lon=lon)
with open(path, "rb") as f:
res = requests.post(
"https://api.genusapi.com/v1/plants/identify",
params=params,
headers={"Authorization": f"Bearer {os.environ['GENUS_KEY']}", "Content-Type": "image/jpeg"},
data=f.read(),
timeout=60,
)
body = res.json()
if not res.ok:
raise RuntimeError(f"{res.status_code} {body['error']}: {body['message']}")
return body
best = identify("photo.jpg", lat=-27.51, lon=153.08)["results"][0]
print(best["name"], best["score"])