ImpSoft.OctopusEnergy.Api
4.0.0-pre.10
.NET 7.0
This package targets .NET 7.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
This is a prerelease version of ImpSoft.OctopusEnergy.Api.
dotnet add package ImpSoft.OctopusEnergy.Api --version 4.0.0-pre.10
NuGet\Install-Package ImpSoft.OctopusEnergy.Api -Version 4.0.0-pre.10
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ImpSoft.OctopusEnergy.Api" Version="4.0.0-pre.10" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ImpSoft.OctopusEnergy.Api --version 4.0.0-pre.10
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ImpSoft.OctopusEnergy.Api, 4.0.0-pre.10"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ImpSoft.OctopusEnergy.Api as a Cake Addin #addin nuget:?package=ImpSoft.OctopusEnergy.Api&version=4.0.0-pre.10&prerelease // Install ImpSoft.OctopusEnergy.Api as a Cake Tool #tool nuget:?package=ImpSoft.OctopusEnergy.Api&version=4.0.0-pre.10&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Octopus Energy client API
A simple .NET Core and .NET Standard client for the Octopus Energy's API https://developer.octopus.energy/docs/api/.
Usage
// Simple console app example
public static async Task Main()
{
// Get your api key, maybe from user secrets
var apiKey = "abcdefg....";
using var httpClient = new HttpClient();
// Optionally set the HttpClient base address.
// If not set it will default to OctopusEnergyClient.DefaultBaseAddress = https://api.octopus.energy
httpClient.BaseAddress = OctopusEnergyClient.DefaultBaseAddress;
// Optionally configure authentication using your api key.
// If the key is not set then api methods that require it will fail (gas/electricity consumption).
httpClient.SetAuthenticationHeaderFromApiKey(apiKey);
// Create the api wrapper
var octopusClient = new OctopusEnergyClient(httpClient);
var account = await octopusClient.GetAccountAsync(accountId);
...
}
async Task GetElectricityConsumption(IOctopusEnergyClient client)
{
var from = new DateTimeOffset(2020, 05, 01, 00, 00, 00, TimeSpan.FromHours(1));
var to = new DateTimeOffset(2020, 05, 11, 23, 59, 00, TimeSpan.FromHours(1));
var consumption = await client.GetElectricityConsumptionAsync(
"<mpan>", "<meter serial>", from, to, Interval.Day);
consumption.ToList()
.ForEach(c => Console.WriteLine(
$"[{c.Start.ToLocalTime()}-{c.End.ToLocalTime()}), {c.Quantity:00.00}"));
}
async Task GetAgileRates(IOctopusEnergyClient client)
{
// Retrieve GSP for postcode (in this case "_C". If 0 or more than 1 GSP is returned an exception will be thrown.
var gsp = (await client.GetGridSupplyPointByPostcodeAsync("SW16 2GY"));
// Alternatively retrieve the GSP using the 'mpan'.
//var gsp = await client.GetGridSupplyPointByMpanAsync("<mpan>");
// the current agile tariff
var productCode = "AGILE-18-02-21";
var agile = await client.GetProductAsync(productCode);
// get the tariff for GSP _C
var tariffCode = agile.SingleRegisterElectricityTariffs.ForGsp(gsp).Monthly.Code;
// get sample quote info
var quote = agile.SampleQuotes.ForGsp(gsp);
var from = new DateTimeOffset(2020, 03, 12, 00, 00, 00, TimeSpan.FromHours(0));
var to = new DateTimeOffset(2020, 03, 12, 23, 59, 00, TimeSpan.FromHours(0));
// retrieve agile tariff rates for desired period
var agileRates = await client.GetElectricityUnitRatesAsync(
productCode, tariffCode, from, to, ElectricityUnitRate.Standard);
agileRates
.Select(r => new {r.ValidFrom, r.ValueIncludingVAT})
.OrderBy(r => r.ValidFrom)
.ToList()
.ForEach(r => Console.WriteLine($"{r.ValidFrom} - {(r.ValueIncludingVAT/100):C4}"));
}
The project uses one or more icons made by <a href="https://www.flaticon.com/authors/flat-icons" title="Flat Icons">Flat Icons</a> from <a href="https://www.flaticon.com/" title="Flaticon"> www.flaticon.com</a>
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 is compatible. 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 is compatible. 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. |
.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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- CommunityToolkit.Diagnostics (>= 8.2.1)
- JetBrains.Annotations (>= 2023.2.0)
- System.Net.Http.Json (>= 7.0.1)
-
net7.0
- CommunityToolkit.Diagnostics (>= 8.2.1)
- JetBrains.Annotations (>= 2023.2.0)
- System.Net.Http.Json (>= 7.0.1)
-
net8.0
- CommunityToolkit.Diagnostics (>= 8.2.1)
- JetBrains.Annotations (>= 2023.2.0)
- System.Net.Http.Json (>= 7.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
none