InfraNode with JavaScript: infranode-sdk
Tutorial: fetch open data for German cities with the keyless TypeScript package infranode-sdk, in Node and the browser, plus a ready-made Vercel AI SDK tool and a Cursor starter template.
Install
npm install infranode-sdk First request
One instance, then any endpoint via a method or the generic
record(slug, endpoint). The data lives under
payload, the source under attribution.
import { InfraNode } from "infranode-sdk";
const api = new InfraNode();
const rec = await api.weather("berlin");
console.log(rec.payload.temperature_c, "degC");
console.log("Source:", rec.attribution.text); // always show attribution
// Any endpoint by name
const fuel = await api.record("hamburg", "fuel-prices");
const cities = await api.cities(); // all 84 cities
Every record carries its own attribution (source and license
URL). The open-data licenses require attribution, so display it to your
users. Errors throw InfraNodeError.
As an AI agent tool: Vercel AI SDK
npm install infranode-sdk ai zod import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
import { infranodeTools } from "infranode-sdk/ai";
const { text } = await generateText({
model: openai("gpt-4o"),
tools: infranodeTools(),
maxSteps: 5,
prompt: "What's the weather and electricity price in Munich right now?",
}); infranodeTools() returns infranode_get_city_data(city,
dataset) and infranode_list_cities(). If your runtime
speaks MCP, use the InfraNode MCP server instead.
Starter template for Cursor
The fastest start: the ready-made dashboard template. It shows weather, air
quality, electricity price and charging points for all 84 cities and ships a
preconfigured .cursor/mcp.json so the InfraNode MCP server is
available to Cursor out of the box.
git clone https://github.com/street1983nk/infranode-weather-starter.git
cd infranode-weather-starter
npm install && npm run dev Learn more
Source and issues: github.com/street1983nk/infranode-js. Template: infranode-weather-starter.
FAQ
- Does it run in the browser?
- Yes. The client uses native fetch and runs in Node 18+ and the browser. The API allows CORS from any origin.
- Do I need an API key?
- No. infranode-sdk talks to the keyless, free InfraNode API. No key, no signup.
- How do I wire it into an AI agent?
- Via the infranode-sdk/ai subpath. infranodeTools() returns ready-made Vercel AI SDK tools you pass to generateText or streamText. ai and zod are optional peer dependencies.