SMARDapi 1.0.8
dotnet add package SMARDapi --version 1.0.8
NuGet\Install-Package SMARDapi -Version 1.0.8
<PackageReference Include="SMARDapi" Version="1.0.8" />
<PackageVersion Include="SMARDapi" Version="1.0.8" />
<PackageReference Include="SMARDapi" />
paket add SMARDapi --version 1.0.8
#r "nuget: SMARDapi, 1.0.8"
#:package SMARDapi@1.0.8
#addin nuget:?package=SMARDapi&version=1.0.8
#tool nuget:?package=SMARDapi&version=1.0.8
SMARDapi for .NET
SMARDapi is a small .NET client for publicly available SMARD (Strommarktdaten) data from the German Federal Network Agency (Bundesnetzagentur). It can retrieve chart and table data for electricity generation, forecasts, market prices, and installed generation capacity.
The library targets netstandard2.0 and net10.0, so it can be used from modern .NET applications and older consumers that still depend on .NET Standard compatibility. The included console app targets net10.0.
Features
- Retrieve SMARD chart index, chart, and table JSON data.
- Query by region, resolution, and SMARD filter type.
- Access electricity generation, forecasts, market prices, and installed capacity.
- Use a convenience client for latest German data or a direct API client for exact endpoints.
- Pass
CancellationTokenthrough all API calls. - Handle API and JSON errors via
SmardApiException.
Installation
Install the SMARDapi NuGet package:
dotnet add package SMARDapi
Quick Start
Use SmardClient when you want the latest available German data without manually looking up the newest timestamp:
using SMARDapi.Models;
using SMARDapi.Models.FilterTypes;
using var client = new SmardClient();
var photovoltaik = await client.GetEnergieartChartData(EnergieartTypes.Photovoltaik);
var latestValue = photovoltaik.Series.LastOrDefault(value => value.Value.HasValue);
Console.WriteLine($"{latestValue?.Timestamp}: {latestValue?.Value} MW");
Table data is available separately and returns a TableResult:
using var client = new SmardClient();
var table = await client.GetEnergieartTableData(EnergieartTypes.WindOnshore);
var latest = table.Series.LastOrDefault(value => value.Value.HasValue);
Installed generation capacity can be queried through the same convenience client:
using var client = new SmardClient();
var installedCapacity = await client.GetInstallierteLeistung(EnergieartTypes.Biomasse);
var latestCapacity = installedCapacity.Series.LastOrDefault(value => value.Value.HasValue);
Direct API Access
Use SmardApiClient when you need exact control over region, resolution, filter, and timestamp:
using SMARDapi.Models;
using SMARDapi.Models.FilterTypes;
using var client = new SmardApiClient();
using var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(30));
var index = await client.GetMarktpreisIndexChartData(
Regions.DE,
Resolutions.Day,
MarktpreisTypes.DeutschlandLuxemburg,
timeout.Token);
var latestTimestamp = index.Timestamps.Last();
var chart = await client.GetMarktpreisChartData(
Regions.DE,
MarktpreisTypes.DeutschlandLuxemburg,
Resolutions.Day,
latestTimestamp,
timeout.Token);
HTTP and JSON failures are reported as SmardApiException:
try
{
var result = await client.GetEnergieartChartData(
Regions.DE,
EnergieartTypes.Photovoltaik,
Resolutions.Hour,
latestTimestamp);
}
catch (SmardApiException ex)
{
Console.WriteLine($"SMARD request failed for {ex.Endpoint}: {ex.Message}");
}
Console App
The repository includes a small net10.0 console app that renders current German production values as ASCII bars:
dotnet run --project SMARDapi.Console
Watch mode refreshes automatically:
dotnet run --project SMARDapi.Console -- --watch --interval=60
Tests
Run the normal test suite:
dotnet test SMARDapi.slnx --no-restore
Smoke tests call live SMARD endpoints and are disabled by default. Enable them explicitly:
$env:SMARDAPI_RUN_SMOKE_TESTS = "1"
dotnet test SMARDapi.Tests\SMARDapi.Tests.csproj --filter TestCategory=Smoke
Releases
NuGet package versions are derived from the git tag. Push tags such as v1.0.7; the release workflow strips the leading v, creates a GitHub Release, attaches the package, and publishes SMARDapi as version 1.0.7.
NuGet publishing uses Trusted Publishing. Configure a nuget.org Trusted Publishing policy for .github/workflows/release.yml and set the GitHub repository variable NUGET_USER to the nuget.org username that created the policy.
Use an annotated tag if you want the tag message to become the GitHub Release notes:
git tag -a v1.0.7 -m "SMARDapi 1.0.7"
git push origin v1.0.7
Do not update a version number in the project files for normal releases. For a local package build, pass the version explicitly:
dotnet pack SMARDapi\SMARDapi.csproj -c Release -p:Version=1.0.7 -p:PackageVersion=1.0.7
License
This library is open source and available under the MIT License.
Disclaimer
This library is not affiliated with or endorsed by the Bundesnetzagentur or the official SMARD website. It is an independent implementation that accesses publicly available SMARD data.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.9)
- System.Text.Json (>= 10.0.9)
-
net10.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.