Skip to content

Latest commit

 

History

History
177 lines (147 loc) · 8.71 KB

File metadata and controls

177 lines (147 loc) · 8.71 KB

EnphaseOpenAPI.Enlighten - the C# library for the The Enlighten Systems API

The Enlighten Systems API is a JSON-based API that provides access to performance data for a PV system. By using the Enlighten Systems API, you agree to the Enphase Energy API License Agreement.

Please note that the Enlighten Systems API does not provide performance data at a panel or microinverter level.

This C# SDK is automatically generated by the OpenAPI Generator project:

  • API version: 2.0
  • SDK version: 1.0.0
  • Build package: org.openapitools.codegen.languages.CSharpNetCoreClientCodegen

Frameworks supported

  • .NET Core >=1.0
  • .NET Framework >=4.6
  • Mono/Xamarin >=vNext

Dependencies

The DLLs included in the package may not be the latest version. We recommend using NuGet to obtain the latest version of the packages:

Install-Package RestSharp
Install-Package Newtonsoft.Json
Install-Package JsonSubTypes
Install-Package System.ComponentModel.Annotations

NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See RestSharp#742. NOTE: RestSharp for .Net Core creates a new socket for each api call, which can lead to a socket exhaustion problem. See RestSharp#1406.

Installation

Generate the DLL using your preferred tool (e.g. dotnet build)

Then include the DLL (under the bin folder) in the C# project, and use the namespaces:

using EnphaseOpenAPI.Enlighten.Api;
using EnphaseOpenAPI.Enlighten.Client;
using EnphaseOpenAPI.Enlighten.Model;

Usage

To use the API client with a HTTP proxy, setup a System.Net.WebProxy

Configuration c = new Configuration();
System.Net.WebProxy webProxy = new System.Net.WebProxy("http://myProxyUrl:80/");
webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
c.Proxy = webProxy;

Getting Started

using System.Collections.Generic;
using System.Diagnostics;
using EnphaseOpenAPI.Enlighten.Api;
using EnphaseOpenAPI.Enlighten.Client;
using EnphaseOpenAPI.Enlighten.Model;

namespace Example
{
    public class Example
    {
        public static void Main()
        {

            Configuration config = new Configuration();
            config.BasePath = "https://api.enphaseenergy.com/api/v2";
            // Configure API key authorization: ApiKey
            config.ApiKey.Add("key", "YOUR_API_KEY");
            // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
            // config.ApiKeyPrefix.Add("key", "Bearer");

            var apiInstance = new DefaultApi(config);
            var userId = 4d6a51330a;  // string | 
            var systemId = 66;  // int | 
            var startDate = Fri Jul 01 10:00:00 AEST 2016;  // DateTimeOffset? | The date on which to start the time series. Defaults to the system's operational date. (optional) 
            var endDate = Sun Jul 31 10:00:00 AEST 2016;  // DateTimeOffset? | The last date to include in the time series. Defaults to yesterday or the last day the system reported, whichever is earlier. (optional) 

            try
            {
                ConsumptionLifetimeResponse result = apiInstance.ConsumptionLifetime(userId, systemId, startDate, endDate);
                Debug.WriteLine(result);
            }
            catch (ApiException e)
            {
                Debug.Print("Exception when calling DefaultApi.ConsumptionLifetime: " + e.Message );
                Debug.Print("Status Code: "+ e.ErrorCode);
                Debug.Print(e.StackTrace);
            }

        }
    }
}

Documentation for API Endpoints

All URIs are relative to https://api.enphaseenergy.com/api/v2

Class Method HTTP request Description
DefaultApi ConsumptionLifetime GET /systems/{system_id}/consumption_lifetime
DefaultApi ConsumptionStats GET /systems/{system_id}/consumption_stats
DefaultApi EnergyLifetime GET /systems/{system_id}/energy_lifetime
DefaultApi Envoys GET /systems/{system_id}/envoys
DefaultApi Inventory GET /systems/{system_id}/inventory
DefaultApi InvertersSummaryByEnvoyOrSite GET /systems/inverters_summary_by_envoy_or_site
DefaultApi MonthlyProduction GET /systems/{system_id}/monthly_production
DefaultApi ProductionMeterReadings GET /systems/{system_id}/production_meter_readings
DefaultApi RgmStats GET /systems/{system_id}/rgm_stats
DefaultApi SearchSystemId GET /systems/search_system_id
DefaultApi Stats GET /systems/{system_id}/stats
DefaultApi Summary GET /systems/{system_id}/summary
DefaultApi Systems GET /systems

Documentation for Models

Documentation for Authorization

ApiKey

  • Type: API key
  • API key parameter name: key
  • Location: URL query string