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/unitsAPI-Keys können in den Einstellungen erstellt werden.
2Endpoints
GET
/api/v1/unitsAnlagen 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, nuclearbundesland(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 stillgelegtinbetriebnahmeVon(date)– ISO-Datum, z.B. "2024-01-01"inbetriebnahmeBis(date)– ISO-DatumgeplanteInbetriebnahmeVon(date)– Geplante IBN ab (für Pipeline-Anlagen)geplanteInbetriebnahmeBis(date)– Geplante IBN bisleistungMin(number)– Min. Leistung in kWleistungMax(number)– Max. Leistung in kWformat(enum)– json (default), geojsonBeispiel
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/:idEinzelne 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/aggregationsAggregierte Statistiken nach Gruppierung
Parameter
groupBy(enum)– energyType, bundeslandenergyType(enum)– Filter auf Energietypbundesland(string)– Filter auf BundeslandBeispiel
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/usageAPI-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
| Plan | Requests/Minute | Rows/Monat |
|---|---|---|
| Pro | 30 | 50.000 |
| Enterprise | 60+ | Individuell |
5Fehlercodes
| Status | Code | Beschreibung |
|---|---|---|
401 | MISSING_API_KEY | X-API-Key Header fehlt |
401 | INVALID_API_KEY | API-Key ungültig oder deaktiviert |
403 | INSUFFICIENT_TIER | Pro oder Enterprise Abo erforderlich |
429 | RATE_LIMIT_EXCEEDED | Rate Limit überschritten |
400 | INVALID_PARAMS | Ungültige Query-Parameter |