Identify and API key
Read the ECM-ID from the box offline, and optionally resolve the model name with a free API key.
identify() reads the ECM-ID from the box: 5 bytes, shown as 10 hex
characters (for example 0101880D01). That needs only the cable and works
offline.
The model name (and maker, ECU code, suggested live profile) comes from the
smongrot API. It needs a free API key from https://developers.smongrot.com.
Without a key nothing breaks: live data and fault codes work the same, and
model is null.
JavaScript
import { connect, smongrotApi } from '@smongrot/sdk';
const api = smongrotApi({ apiKey: process.env.SMONGROT_API_KEY });
const s = await connect(transport, { lookupModel: api.lookupModel });
const id = await s.identify();
console.log(id.ecmId); // "0101880D01", read from the box
console.log(id.model?.model ?? '—'); // model name (may be Thai), or "—" if unknown / offline / no key
Dart
final api = SmongrotApi(apiKey: myKey);
final s = await connect(transport, lookupModel: api.lookupModel);
final id = await s.identify();
print(id.ecmId);
print(id.model?.model ?? '—');
What model holds
| Field | |
|---|---|
model |
model name as riders know it. It can be in Thai and has no model year. |
maker |
keihin or shindengen (also picks the fault-code decoder) |
ecuCode |
full part code, e.g. 38770-K03-H01 (also set as partCode) |
liveProfile |
suggested live profile id. Often null; live() detects the profile on its own, so you never need it. |
verified |
true if this ECM-ID was confirmed on a real box |
ecmId |
the ECM-ID the API answered for |
Example data: {"ecm_id": "0101880D01", "maker": "keihin", "model": "<model name>", "ecu_code": "38770-K03-H01", "live_profile": null, "verified": true}.
The request
GET https://api.smongrot.com/v1/ecu/identify?ecm=<10 hex> with
Authorization: Bearer <your key>. Success is { "data": { "ecm_id", "maker", "model", "ecu_code", "live_profile", "verified" } }; errors are
{ "error": { "code", "message", "docs_url" } }. Only the ECM-ID is sent.
Errors never break identify
lookupModel never throws. An unknown ECU (404), a bad key, a rate limit, a
timeout (5 s default, timeoutMs / timeout) or no network all give
model: null. To see why, pass onError:
smongrotApi({ apiKey, onError: (e) => console.warn(e.code, e.message) });
Codes: API_UNAUTHORIZED, API_RATE_LIMITED, API_NETWORK, API_ERROR,
API_BAD_RESPONSE, API_BAD_INPUT. A missing key is a programming error and
throws NO_API_KEY when you create the helper, not during identify.
Keep the key private
Do not put the key in a public web page. In a browser app, call the API from
your own server and pass your own lookupModel(ecmId) to connect; any
function returning { model, maker, ... } or null works.
Next: Protocol overview