OpenElectricity TypeScript Client
The OpenElectricity TypeScript client is currently in beta and still under active development.
The OpenElectricity TypeScript client is the official library for accessing the OpenElectricity API, providing simplified access to Australian electricity network data. This client supports both browser and Node.js environments, offering a type-safe interface to work with electricity data from the National Electricity Market (NEM) and Western Australian Electricity Market (WEM).
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 powerful DataTable
class that provides a pandas/polars-like interface for analyzing time series data.
DataTable Overview
The DataTable
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:
Supported aggregation methods:
"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:
The 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
The DataTable
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)