Docs menu

SDKs

Two SDKs sign every request the way the API verifies it and verify webhook signatures. Neither is published yet: npm and PyPI packages arrive with the release. Other languages: generate a client from openapi.yaml.

TypeScriptPython
Package@tenergy/sdk (npm, on release)tenergy (PyPI, on release)
Installnpm install @tenergy/sdkpip install tenergy
Webhook checkverifyWebhookSignature(secret, timestamp, rawBody, signature)verify_signature(secret, headers, body, tolerance_seconds=300)
Example projecttenergy-examples-tstenergy-examples-py
Full referenceTypeScript SDKthis page

TypeScript

import { TenergyClient } from "@tenergy/sdk";
const client = new TenergyClient({ baseUrl: "https://api-nile.tenergy.me/v1", apiKey: process.env.TENERGY_KEY!, apiSecret: process.env.TENERGY_SECRET! });
const quote = await client.createQuote({ resource: "energy", amount: 65_000, tier: "1h", receiver });
const order = await client.createOrder({ quote_id: quote.id, client_order_id: `qs-${crypto.randomUUID()}` });
const settled = await client.waitForOrder(order.id, { timeoutMs: 120_000 });

Python

import os, uuid
from tenergy import Client
client = Client(api_key=os.environ["TENERGY_KEY"], api_secret=os.environ["TENERGY_SECRET"], base_url="https://api-nile.tenergy.me/v1")
quote = client.create_quote({"resource": "energy", "amount": 65000, "tier": "1h", "receiver": receiver})
order = client.create_order({"quote_id": quote["id"], "client_order_id": f"qs-{uuid.uuid4()}"})

Poll client.get_order(order["id"]) until the status is active, or wait for the order.confirmed webhook.

Runnable quickstarts

Both projects walk prices → estimate → key → deposit → order → settled and print each step; any API error prints its slug and request id.

ProjectRunNeeds
examples/ts-quickstartnpm install && npx tsx quickstart.tsNode.js 18+; RECEIVER_ADDRESS; TENERGY_KEY/TENERGY_SECRET, or it signs up with a generated wallet on Nile
examples/py-quickstartpip install -e . && python quickstart.pyPython 3.9+; TENERGY_KEY/TENERGY_SECRET from /app

Keys are available right after signup; only the order needs a balance. Create the key before the deposit: the signup token lives 15 minutes, a deposit takes about a minute of confirmations. The five-step Nile run is in Environments.

    ↑ ↓ to move · Enter to open · Esc to close