UNPKG

@wayota/redata-api-client

Version:

TypeScript client for the REData (Red Eléctrica de España) public API. Provides convenient methods to fetch Spanish electricity data widgets, supporting category, widget, date range, and geographic filters. The client is based on a custom OpenAPI specific

29 lines (27 loc) 1.02 kB
import { Client } from "./Client" import { RegionGeo } from "./constants/RegionGeo"; import { Category } from "./enums/Category"; import { GeoLimit } from "./enums/GeoLimit"; import { GeoTrunc } from "./enums/GeoTrunc"; import { TimeTrunc } from "./enums/TimeTrunc"; import { Widget } from "./enums/Widget"; const main = async () => { const client = new Client(); const response = await client.getByCategoryByWidget({ category: Category.balance, widget: Widget.balanceElectrico, query: { startDate: '2019-01-01T00:00', endDate: '2019-01-31T23:59', timeTrunc: TimeTrunc.day, geotrunc: GeoTrunc.electricSystem, // Optional, if needed geoLimit: GeoLimit.canarias, // Optional, if needed geoIds: RegionGeo.Canarias.geoId.toString(), // Optional, if needed } }); console.log(response); }; main().catch((error) => { console.error('Error:', error); process.exit(1); });