Hoi Mark, Johan,
Na het ‘tegenkomen’ van ned.nl vond ik dit topic.
Nu heb ik het voor elkaar gekregen om gegevens zoals ‘type’ e.d. op te vragen via de API handleiding.
Dit scriptje hieronder zou hetzelfde moeten doen uit dat API voorbeeld, maar ja maar ja…
Ik ben dus erg benieuwd hoe je bijv. de zonverwachting opvraagt.
// API page: https://api.ned.nl/v1#/
// https://ned.nl/datacatalogus
// https://ned.nl/nl/handleiding-api
const myAPIKey = 'abc123'; // change into personal API key here
// get date in yyyy-mm-dd format //
const dateIso = new Date().toISOString.substring(0,10);
const dateStart = '2025-05-16'; // enter start date (todo: coded date)
const dateEnd = dateIso; // today's date
const baseURL = 'https://api.ned.nl/v1';
//// Parameters to send along with the request ////
//// Point: 0 - Netherlands
//// Type: 2 - Solar
//// Granularity 3 = 10 min
//// Timezone 1 = EU/AMS
//// Classification 2 = current
//// Activity 1 = providing
//// Validfromstrictlybefore = yyyy-mm-dd
//// Validfromafter = yyyy-mm-dd
//// Test getting some values:
////const URL = baseURL + `\types?page=1&itemsPerPage=30`;
const URL = baseURL + `utilizations?point=0&type=2&granularity=3&granularitytimezone=1&classification=2&activity=1&validfrom[strictly_before]=${dateEnd}&validfrom[after]=${dateStart}`;
const res = await fetch(URL, {
headers : {
"X-AUTH-TOKEN": myAPIKey,
accept: "application/ld+json"
}
});
if (!res.ok) {
throw new Error(res.status + '\n' + res.json); // 401 = unauthorised, 404 = not found
return false;
}
const json = await res.json();
//const value = json.value;
log (json);
return true;