Voor onze marktprijzen heb je geen authenticate nodig. Om de marktprijzen op te halen kun je een POST call doen naar https://graphql.frankenergie.nl/ met dit als GraphQL query:
Om dit als JSON mee te sturen moet je de bovenstaande query escapen en meegeven als query
property, de body van de POST call wordt dan iets als:
query MarketPrices {
marketPrices(date:"2022-01-01") {
electricityPrices {
from
till
marketPrice
marketPriceTax
sourcingMarkupPrice
energyTaxPrice
perUnit
}
gasPrices {
from
till
marketPrice
marketPriceTax
sourcingMarkupPrice
energyTaxPrice
perUnit
}
}
}
{"query":"query MarketPrices {\\n marketPrices(date:\\"2022-01-01\\") {\\n electricityPrices {\\n from\\n till\\n marketPrice\\n marketPriceTax\\n sourcingMarkupPrice\\n energyTaxPrice\\n perUnit\\n }\\n gasPrices {\\n from\\n till\\n marketPrice\\n marketPriceTax\\n sourcingMarkupPrice\\n energyTaxPrice\\n perUnit\\n }\\n }\\n}\\n"}
Voor marktprijzen in België voeg je een
x-country
header toe met waardeBE
JavaScript code voorbeeld
query MarketPrices {
marketPrices(date:"2022-01-01") {
electricityPrices {
from
till
marketPrice
marketPriceTax
sourcingMarkupPrice
energyTaxPrice
perUnit
}
gasPrices {
from
till
marketPrice
marketPriceTax
sourcingMarkupPrice
energyTaxPrice
perUnit
}
}
}
async function getMarketPrices() {
const marketPrices = await fetch(`https://graphql.frankenergie.nl`, {
method: "POST",
body: JSON.stringify({ query: query }),
headers: {
"content-type":"application/json"
}
}).then((response) => response.json());
console.log(marketPrices);
}
getMarketPrices();