The OpenElectricity TypeScript client is currently in beta and still under active development.
Features
- Cross-platform support (Browser & Node.js)
- Built-in data analysis tools
- Real-time electricity data access
- Timezone-aware date handling
- Time series data manipulation
- Facility and unit information
- Market data access
Getting Started
Installation
The Typescript SDK is available on NPM.Quick Start
Data Analysis
The OpenElectricity client includes a powerfulDataTable
class that provides a pandas/polars-like interface for analyzing time series data.
DataTable Overview
TheDataTable
class provides methods for:
- Filtering and selecting data
- Grouping and aggregating
- Sorting and ordering
- Statistical analysis
- Data transformation
Core Methods
Accessing Data
Filtering
Filter rows based on a condition:Selecting Columns
Select specific columns to work with:Grouping and Aggregation
Group data and calculate aggregates:"sum"
: Calculate the sum of values"mean"
: Calculate the arithmetic mean
Sorting
Sort data by one or more columns:Statistical Analysis
Calculate summary statistics for numeric columns:describe()
method returns statistics including:
count
: Number of non-null valuesmean
: Arithmetic meanstd
: Standard deviationmin
: Minimum valueq25
: 25th percentilemedian
: 50th percentileq75
: 75th percentilemax
: Maximum value
Performance Considerations
TheDataTable
class includes several optimizations:
- Caching: Results of grouping and sorting operations are cached
- Indexed Filtering: Simple equality filters use column indexes
- Single-Pass Operations: Many operations are optimized to process data in a single pass
- Memory Efficiency: Data structures are reused where possible
Type Reference
Network Types
NetworkCode
Represents the supported electricity networks:NEM
: National Electricity Market (Eastern and Southern Australia)WEM
: Western Australian Electricity MarketAU
: Australia-wide (defaults to NEM timezone)
DataInterval
Supported time intervals for data aggregation:Metric Types
DataMetric
Metrics available for network and facility data:MarketMetric
Metrics available for market data:Response Types
ITimeSeriesResponse
Standard response type for time series data:FacilityResponse
Response type for facility queries:Common Patterns and Examples
Basic Data Retrieval
Analyzing Generation Mix
Calculating Emission Factors
Error Handling
The client throws specific error types:OpenElectricityError
: General API errorsNoDataFound
: When no data matches the query (416 status)