1KEY Developers
Get started

SDKs

SDKs

Clients for TypeScript, Python and Elixir wrap the API the same way: one client per API key, errors with type, request_id and doc_url, retries for network errors, 429, 500 and 502–504, an automatic Idempotency-Key on every command, and an event follower that resumes from your cursor.

import { OneKey } from "@1key/api";

const onekey = new OneKey({ apiKey: process.env.ONEKEY_API_KEY });
const { data: hubs } = await onekey.hubs.list();
await onekey.devices.command(hubs[0].id, 7, { key: "lock", value: false });

for await (const event of onekey.events.follow({ after: savedCursor })) {
  handle(event);
  saveCursor(event.cursor);
}
Language Package Install
TypeScript / JavaScript (Node 18+) @1key/api npm install @1key/api
Python 3.9+ onekey-api pip install onekey-api
Elixir onekey {:onekey, "~> 1.0"} in mix.exs

What every SDK does

Errors An error carries the API's type, message, request_id and doc_url. Branch on type
Retries Network errors, 429 (after Retry-After), 500 and 502–504, up to three times. A POST is retried only when it carries an Idempotency-Key or got 429, so nothing is created twice
Commands Sent with an Idempotency-Key, a new UUID unless you pass one, so a retried command runs once
Paging Iterate every site or hub without handling starting_after
Events Follow your organization's event log (or one hub's) from a cursor, holding each request open; an expired cursor raises cursor_expired: read current state, then follow from the newest event