SDKs
Both are tiny, dependency-free wrappers around the REST API, for server-side code only. They are not on npm / PyPI
yet: ask for the files, or copy them from the repository (sdks/js, sdks/python).
JavaScript / TypeScript (Node 18+, Bun, Deno, edge)
import { Esemes, EsemesError, verifyWebhook } from "@esemes/gateway"
const esemes = new Esemes({ apiKey: process.env.ESEMES_KEY! }) // smt_... while developing
await esemes.messages.send({ to: "5123 4567", body: "Your ticket is ready", idempotency_key: "order-1042" })
const { otp_id, test_code } = await esemes.otp.send({ to: "5123 4567" })
const { valid, reason } = await esemes.otp.verify({ otp_id, code: userInput })
try {
await esemes.messages.send({ to: "+33612345678", body: "x" })
} catch (e) {
if (e instanceof EsemesError && e.code === "country_not_allowed") { /* show a nice error */ }
}
// webhook route: the RAW body
const ok = await verifyWebhook(rawBody, signatureHeader, process.env.ESEMES_WEBHOOK_SECRET!)
Python (3.9+, standard library only)
from esemes import Esemes, EsemesError, verify_webhook
esemes = Esemes(os.environ["ESEMES_KEY"])
esemes.messages.send("5123 4567", "Your ticket is ready", idempotency_key="order-1042")
sent = esemes.otp.send("5123 4567")
result = esemes.otp.verify(user_input, otp_id=sent["otp_id"])
ok = verify_webhook(request.body, request.headers["X-SMS-Signature"], os.environ["ESEMES_WEBHOOK_SECRET"])
Errors carry status, code (see Errors) and the Retry-After seconds for 429s.