API Dokumentation

Programmatischer Zugriff auf MaStR-Energiedaten für PRO und Enterprise Kunden.

1Authentifizierung

Alle API-Anfragen benötigen einen gültigen API-Key im Header:

curl -H "X-API-Key: ohmn_DEIN_API_KEY" \
  https://app.ohmnify.io/api/v1/units

API-Keys können in den Einstellungen erstellt werden.

2Endpoints

GET/api/v1/units

Anlagen abfragen mit Filtern und Pagination

Parameter

limit(number)Max. Ergebnisse (1-1000, default: 100)
cursor(string)Pagination Cursor (Format: leistung:mastr_nummer)
energyType(enum)solar, wind, storage, biomass, hydro, geothermal, combustion, nuclear
bundesland(string)z.B. "Bayern"
plz(string)PLZ-Prefix, z.B. "80"
landkreis(string)z.B. "München"
gemeinde(string)z.B. "München"
status(enum)In Betrieb, In Planung, Stillgelegt, Vorübergehend stillgelegt
inbetriebnahmeVon(date)ISO-Datum, z.B. "2024-01-01"
inbetriebnahmeBis(date)ISO-Datum
geplanteInbetriebnahmeVon(date)Geplante IBN ab (für Pipeline-Anlagen)
geplanteInbetriebnahmeBis(date)Geplante IBN bis
leistungMin(number)Min. Leistung in kW
leistungMax(number)Max. Leistung in kW
format(enum)json (default), geojson

Beispiel

curl -H "X-API-Key: ohmn_xxx" \
  "https://app.ohmnify.io/api/v1/units?energyType=solar&bundesland=Bayern&limit=10"

Response

{
  "data": [
    {
      "mastrNummer": "SEE123456789",
      "einheitTyp": "SOLAR",
      "name": "PV-Anlage Dachfläche",
      "status": "In Betrieb",
      "bruttoleistung": 9.8,
      "inbetriebnahme": "2024-03-15",
      "geplanteInbetriebnahme": null,
      "bundesland": "Bayern",
      "plz": "80331",
      "latitude": 48.1351,
      "longitude": 11.5820
    }
  ],
  "meta": {
    "count": 10,
    "cursor": "9.8:SEE123456789",
    "hasMore": true
  }
}
GET/api/v1/units/:id

Einzelne Anlage mit allen Details abrufen

Parameter

id(string)MaStR-Nummer (z.B. SEE123456789)

Beispiel

curl -H "X-API-Key: ohmn_xxx" \
  "https://app.ohmnify.io/api/v1/units/SEE123456789"

Response

{
  "data": {
    "mastrNummer": "SEE123456789",
    "einheitTyp": "SOLAR",
    "name": "PV-Anlage Dachfläche",
    "bruttoleistung": 9.8,
    "betreiber": "Max Mustermann",
    "lage": "Gebäude",
    "hauptausrichtung": "Süd",
    "anzahlModule": 28,
    ...
  }
}
GET/api/v1/aggregations

Aggregierte Statistiken nach Gruppierung

Parameter

groupBy(enum)energyType, bundesland
energyType(enum)Filter auf Energietyp
bundesland(string)Filter auf Bundesland

Beispiel

curl -H "X-API-Key: ohmn_xxx" \
  "https://app.ohmnify.io/api/v1/aggregations?groupBy=bundesland&energyType=wind"

Response

{
  "data": {
    "groupBy": "bundesland",
    "groups": [
      { "bundesland": "Niedersachsen", "count": 6245, "totalMw": 12450.5, "inBetriebCount": 6100, "inBetriebMw": 12200.3 },
      { "bundesland": "Schleswig-Holstein", "count": 3890, "totalMw": 8230.2, "inBetriebCount": 3800, "inBetriebMw": 8100.1 }
    ],
    "totals": { "count": 32156, "totalMw": 68450.7 }
  }
}
GET/api/v1/usage

API-Nutzung und Kontingent prüfen

Beispiel

curl -H "X-API-Key: ohmn_xxx" \
  "https://app.ohmnify.io/api/v1/usage"

Response

{
  "data": {
    "tier": "PRO",
    "rateLimit": { "requests": 30, "window": "1 m" },
    "usage": { "rowsExported": 12500, "rowsLimit": 50000 }
  }
}

3Code-Beispiele

JavaScript / Node.js

const API_KEY = 'ohmn_xxx';
const BASE_URL = 'https://app.ohmnify.io/api/v1';

async function fetchSolarUnits(bundesland) {
  const params = new URLSearchParams({
    energyType: 'solar',
    bundesland,
    limit: '100'
  });
  
  const response = await fetch(`${BASE_URL}/units?${params}`, {
    headers: { 'X-API-Key': API_KEY }
  });
  
  if (!response.ok) {
    throw new Error(`API Error: ${response.status}`);
  }
  
  return response.json();
}

// Pagination durchlaufen
async function fetchAllUnits() {
  let cursor = null;
  const allUnits = [];
  
  do {
    const params = new URLSearchParams({ limit: '1000' });
    if (cursor) params.set('cursor', cursor);
    
    const { data, meta } = await fetch(
      `${BASE_URL}/units?${params}`,
      { headers: { 'X-API-Key': API_KEY } }
    ).then(r => r.json());
    
    allUnits.push(...data);
    cursor = meta.hasMore ? meta.cursor : null;
  } while (cursor);
  
  return allUnits;
}

Python

import requests

API_KEY = 'ohmn_xxx'
BASE_URL = 'https://app.ohmnify.io/api/v1'

headers = {'X-API-Key': API_KEY}

# Alle Windkraftanlagen in Niedersachsen
response = requests.get(
    f'{BASE_URL}/units',
    headers=headers,
    params={
        'energyType': 'wind',
        'bundesland': 'Niedersachsen',
        'limit': 100
    }
)

data = response.json()
print(f"Gefunden: {data['meta']['count']} Anlagen")

for unit in data['data']:
    print(f"{unit['name']}: {unit['bruttoleistung']} kW")

# Aggregation abrufen
agg = requests.get(
    f'{BASE_URL}/aggregations',
    headers=headers,
    params={'groupBy': 'energyType'}
).json()

for group in agg['data']['groups']:
    print(f"{group['energyType']}: {group['totalMw']} MW")

4Rate Limits

PlanRequests/MinuteRows/Monat
Pro3050.000
Enterprise60+Individuell

5Fehlercodes

StatusCodeBeschreibung
401MISSING_API_KEYX-API-Key Header fehlt
401INVALID_API_KEYAPI-Key ungültig oder deaktiviert
403INSUFFICIENT_TIERPro oder Enterprise Abo erforderlich
429RATE_LIMIT_EXCEEDEDRate Limit überschritten
400INVALID_PARAMSUngültige Query-Parameter