Best Practices
Optimize your GridStatus API usage for performance, reliability, and cost-effectiveness.
Query Optimization
1
Always Use Time Filters
# Queries entire dataset - slow and expensive
curl "https://api.gridstatus.io/v1/datasets/ercot_lmp_by_settlement_point/query?api_key=YOUR_API_KEY"# Bounded time range with location filter - fast and efficient
curl "https://api.gridstatus.io/v1/datasets/ercot_lmp_by_settlement_point/query?\
start_time=2026-01-01&\
end_time=2026-01-02&\
filter_column=location&\
filter_value=HB_HOUSTON&\
api_key=YOUR_API_KEY"2
Filter by Subseries
# Returns data for all 10,000+ nodes
curl "https://api.gridstatus.io/v1/datasets/pjm_lmp_real_time_5_min/query?api_key=YOUR_API_KEY"# Returns data for one specific hub
curl "https://api.gridstatus.io/v1/datasets/pjm_lmp_real_time_5_min/query?\
start_time=2026-01-01&\
end_time=2026-01-02&\
filter_column=location&\
filter_value=WESTERN%20HUB&\
api_key=YOUR_API_KEY"3
Select Only Needed Columns
# Only get timestamp, location, and LMP
curl "https://api.gridstatus.io/v1/datasets/caiso_lmp_real_time_5_min/query?\
start_time=2026-01-01&\
end_time=2026-01-02&\
columns=interval_start_utc,location,lmp&\
filter_column=location&\
filter_value=TH_SP15_GEN-APND&\
api_key=YOUR_API_KEY"# Only get timestamp, location, and LMP - skip energy, congestion, loss components
df = client.get_dataset(
"caiso_lmp_real_time_5_min",
start="2026-01-01",
end="2026-01-02",
columns=["interval_start_utc", "location", "lmp"],
filter_column="location",
filter_value="TH_SP15_GEN-APND"
)
# Response is ~60% smaller than without column selection4
Pagination Strategies
Use Cursor Pagination for Large Datasets
# The client handles pagination automatically - no manual cursor management needed
df = client.get_dataset(
"ercot_fuel_mix",
start="2026-01-01",
end="2026-01-02"
)
# All pages are fetched and combined into a single DataFrame
print(f"Retrieved {len(df)} total rows")Batch Large Date Ranges
Caching Strategies
Cache Static Data
Cache Frequently Accessed Data
Error Handling
Implement Retry Logic
Monitor API Usage
Data Quality
Verify Data Freshness
Validate Query Results
Performance Summary
Practice
Impact
Implementation
Related Documentation
Last updated
Was this helpful?

