Quick start with the Leafy Energy JS/TS SDK
The JavaScript/TypeScript SDK is the natural starting point if you want to integrate Leafy Energy into web apps or Node.js services. In these demo docs we show what it might look like.
Installation (concept)
npm install @leafyenergy/sdk
# or
yarn add @leafyenergy/sdk
Simple example
import { LeafyClient } from "@leafyenergy/sdk";
const client = new LeafyClient({
apiKey: "YOUR_SANDBOX_API_KEY",
baseUrl: "https://api.sandbox.leafy.energy"
});
async function showCurrentPrice() {
const price = await client.pricing.getCurrentPrice({ siteId: "home_001" });
console.log("Current price:", price.value, price.currency, "per kWh");
}
In a demo environment you can use this snippet to show live how easy it is to fetch pricing or consumption data.
Comments
0 comments
Please sign in to leave a comment.