energy-data API

API documentation

All requests go to https://www.mergistics.com and return JSON. You need an API key from us; it starts with ek_. Keep it private, like a password.

Authentication

Using the API takes two steps:

  1. Send your API key to POST /api/token in an X-API-Key header. You get back an access token (starting with et_) that's valid for 60 minutes:
    {"access_token": "et_...", "token_type": "Bearer", "expires_in": 3600, "expires_at": "2026-11-24T21:00:00+00:00"}
  2. Send the token with every data request in an Authorization: Bearer et_... header. When it expires (you'll get a 401), request a new one. Data endpoints don't accept the API key itself.

To check your token and see what your subscription includes, call GET /api/whoami. The examples below do both steps; replace ek_your_key_here with your key.

Responses, paging and sorting

Endpoints that return lists are paged. The response looks like this:

{
  "data":  [ {...}, {...} ],      // the rows on this page
  "page":  1,                     // this page number
  "limit": 100,                   // rows per page
  "total": 734,                   // rows matching your filters, across all pages
  "pages": 8,                     // number of pages
  "sort":  "-day,location",       // the sort that was applied
  "next":  "https://www.mergistics.com/api/...&page=2",   // full URL of the next page, or null on the last page
  "prev":  null                   // full URL of the previous page, or null on the first page
}

Errors

Errors return a JSON body like {"error": "can't sort by 'x'; choose from: ..."} with one of these status codes:

StatusMeaning
400A parameter is invalid. The message says which one and why.
401The API key or access token is missing, wrong, expired or revoked. Request a new token; if that fails too, contact us about your key.
403Your subscription doesn't include this endpoint.
404There's no endpoint at that path.
405The endpoint doesn't accept that HTTP method. The Allow header lists the ones it does.
503The data isn't available yet. Try again later.

Endpoints

GET /api/weather/daily requires: api_read

Daily low, high and average temperatures for each city, from hourly forecasts.

Parameters (all optional)

locationCity name, e.g. Chicago (not case-sensitive). Default: all cities.
startFirst day to include, YYYY-MM-DD.
endLast day to include, YYYY-MM-DD.
sortColumns to sort by, comma-separated and applied left to right; put - in front of a column for descending. Columns: day, location, temp_min_f, temp_max_f, temp_avg_f, hours. Default: -day,location.
pagePage number, starting at 1. Default: 1.
limitRows per page, 1 to 1000. Default: 100.

Example

import requests

BASE_URL = "https://www.mergistics.com"
API_KEY = "ek_your_key_here"

# 1. Exchange your API key for an access token (valid 60 minutes)
resp = requests.post(f"{BASE_URL}/api/token", headers={"X-API-Key": API_KEY})
resp.raise_for_status()
token = resp.json()["access_token"]

# 2. Call the endpoint with the token
resp = requests.request(
    "GET",
    f"{BASE_URL}/api/weather/daily",
    headers={"Authorization": f"Bearer {token}"},
    params={"location": "Chicago", "start": "2026-11-01", "sort": "-temp_max_f,day", "limit": 5},
)
resp.raise_for_status()
body = resp.json()
print(f"{body['total']} rows, page {body['page']} of {body['pages']}")
for row in body["data"]:
    print(row)
<?php
$baseUrl = "https://www.mergistics.com";
$apiKey  = "ek_your_key_here";

function apiRequest(string $method, string $url, array $headers, ?array $json = null): array {
    $ch = curl_init($url);
    curl_setopt_array($ch, [
        CURLOPT_CUSTOMREQUEST  => $method,
        CURLOPT_HTTPHEADER     => $json === null ? $headers : [...$headers, "Content-Type: application/json"],
        CURLOPT_POSTFIELDS     => $json === null ? "" : json_encode($json),
        CURLOPT_RETURNTRANSFER => true,
    ]);
    $raw = curl_exec($ch);
    if ($raw === false) {
        throw new RuntimeException(curl_error($ch));
    }
    $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $data = json_decode($raw, true);
    if ($status >= 400) {
        throw new RuntimeException("HTTP $status: " . ($data["error"] ?? $raw));
    }
    return $data;
}

// 1. Exchange your API key for an access token (valid 60 minutes)
$token = apiRequest("POST", "$baseUrl/api/token", ["X-API-Key: $apiKey"])["access_token"];

// 2. Call the endpoint with the token
$params = ["location" => "Chicago", "start" => "2026-11-01", "sort" => "-temp_max_f,day", "limit" => 5];
$body = apiRequest("GET", "$baseUrl/api/weather/daily?" . http_build_query($params), ["Authorization: Bearer $token"]);
echo "{$body['total']} rows, page {$body['page']} of {$body['pages']}\n";
foreach ($body["data"] as $row) {
    echo json_encode($row), "\n";
}
BASE_URL="https://www.mergistics.com"
API_KEY="ek_your_key_here"

# 1. Exchange your API key for an access token (jq reads the JSON: https://jqlang.org)
TOKEN=$(curl -s -X POST "$BASE_URL/api/token" -H "X-API-Key: $API_KEY" | jq -r .access_token)

# 2. Call the endpoint with the token
curl -s -G "$BASE_URL/api/weather/daily" \
  -H "Authorization: Bearer $TOKEN" \
  --data-urlencode "location=Chicago" \
  --data-urlencode "start=2026-11-01" \
  --data-urlencode "sort=-temp_max_f,day" \
  --data-urlencode "limit=5" | jq .
$BaseUrl = "https://www.mergistics.com"
$ApiKey  = "ek_your_key_here"

# 1. Exchange your API key for an access token (valid 60 minutes)
$Token = (Invoke-RestMethod -Method Post -Uri "$BaseUrl/api/token" -Headers @{ "X-API-Key" = $ApiKey }).access_token

# 2. Call the endpoint with the token
$Params = @{ location = "Chicago"; start = "2026-11-01"; sort = "-temp_max_f,day"; limit = 5 }
$Body = Invoke-RestMethod -Method Get -Uri "$BaseUrl/api/weather/daily" -Headers @{ Authorization = "Bearer $Token" } -Body $Params
"$($Body.total) rows, page $($Body.page) of $($Body.pages)"
$Body.data | Format-Table
GET /v1/energy/plant-performance requires: api_read

Monthly net generation and estimated capacity factor for U.S. power plants, from EIA-860M / EIA-860 capacity and EIA-923 generation.

Parameters (all optional)

plant_idEIA plant code, e.g. 3 (Barry, AL).
stateTwo-letter state code, e.g. NC.
yearReporting year, e.g. 2025.
monthMonth number, 1-12.
capacity_sourceeia860m (monthly capacity) or eia860 (annual capacity).
min_capacity_mwOnly plants with at least this much capacity (MW). Excludes rows with no capacity.
limitRows per page, 1 to 1000. Default: 100.
offsetRows to skip, for paging. Default: 0.

Example

import requests

BASE_URL = "https://www.mergistics.com"
API_KEY = "ek_your_key_here"

# 1. Exchange your API key for an access token (valid 60 minutes)
resp = requests.post(f"{BASE_URL}/api/token", headers={"X-API-Key": API_KEY})
resp.raise_for_status()
token = resp.json()["access_token"]

# 2. Call the endpoint with the token
resp = requests.request(
    "GET",
    f"{BASE_URL}/v1/energy/plant-performance",
    headers={"Authorization": f"Bearer {token}"},
    params={"state": "NC", "year": 2025, "month": 6, "limit": 100, "offset": 0},
)
resp.raise_for_status()
print(resp.json())
<?php
$baseUrl = "https://www.mergistics.com";
$apiKey  = "ek_your_key_here";

function apiRequest(string $method, string $url, array $headers, ?array $json = null): array {
    $ch = curl_init($url);
    curl_setopt_array($ch, [
        CURLOPT_CUSTOMREQUEST  => $method,
        CURLOPT_HTTPHEADER     => $json === null ? $headers : [...$headers, "Content-Type: application/json"],
        CURLOPT_POSTFIELDS     => $json === null ? "" : json_encode($json),
        CURLOPT_RETURNTRANSFER => true,
    ]);
    $raw = curl_exec($ch);
    if ($raw === false) {
        throw new RuntimeException(curl_error($ch));
    }
    $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $data = json_decode($raw, true);
    if ($status >= 400) {
        throw new RuntimeException("HTTP $status: " . ($data["error"] ?? $raw));
    }
    return $data;
}

// 1. Exchange your API key for an access token (valid 60 minutes)
$token = apiRequest("POST", "$baseUrl/api/token", ["X-API-Key: $apiKey"])["access_token"];

// 2. Call the endpoint with the token
$params = ["state" => "NC", "year" => 2025, "month" => 6, "limit" => 100, "offset" => 0];
$body = apiRequest("GET", "$baseUrl/v1/energy/plant-performance?" . http_build_query($params), ["Authorization: Bearer $token"]);
print_r($body);
BASE_URL="https://www.mergistics.com"
API_KEY="ek_your_key_here"

# 1. Exchange your API key for an access token (jq reads the JSON: https://jqlang.org)
TOKEN=$(curl -s -X POST "$BASE_URL/api/token" -H "X-API-Key: $API_KEY" | jq -r .access_token)

# 2. Call the endpoint with the token
curl -s -G "$BASE_URL/v1/energy/plant-performance" \
  -H "Authorization: Bearer $TOKEN" \
  --data-urlencode "state=NC" \
  --data-urlencode "year=2025" \
  --data-urlencode "month=6" \
  --data-urlencode "limit=100" \
  --data-urlencode "offset=0" | jq .
$BaseUrl = "https://www.mergistics.com"
$ApiKey  = "ek_your_key_here"

# 1. Exchange your API key for an access token (valid 60 minutes)
$Token = (Invoke-RestMethod -Method Post -Uri "$BaseUrl/api/token" -Headers @{ "X-API-Key" = $ApiKey }).access_token

# 2. Call the endpoint with the token
$Params = @{ state = "NC"; year = 2025; month = 6; limit = 100; offset = 0 }
$Body = Invoke-RestMethod -Method Get -Uri "$BaseUrl/v1/energy/plant-performance" -Headers @{ Authorization = "Bearer $Token" } -Body $Params
$Body

The curl examples are for macOS/Linux shells and use jq to read JSON. On Windows, use the PowerShell examples.