Working with Production Devices

Derapi makes it easy to acquire, use and maintain credentials for vendor APIs and devices. Acquiring vendor API credentials and authorizing end-customer devices varies between DER vendors. This section contains instructions on how to get credentials for each vendor and associate customer-owned devices with your credentials.

To access vendor DERs please contact us ([email protected]) to request Production mode credentials.

Derapi Join

Derapi provides Derapi Join for end-customer authorization. Join is the client-side component that your end-customer will use to authorize their DERs. Join allows you, the application developer, to embed a simple, intuitive UI in your customer experience to capture end-customer authorization.

Integrate Join with your app

To integrate Derapi Join into your website, simply follow the instructions below.
Add this script tag to your HTML:

<script src="https://raw.githubusercontent.com/derapi/derapi/main/join/derapi-join.js"></script>

Join requires a Join session to be created. A POST request to https://api.derapi.com/join/session/start will return a session_id. Once the session ID token is created, pass it into the JS function derapi.createJoin() like this:

  import derapi from "https://raw.githubusercontent.com/derapi/derapi/main/join/derapi-join.js";
  const onSuccess = () => {
      alert('success!');
  }
  const onClose = () => {
      alert('closed');
  }
  const join = derapi.createJoin(sessionToken, onSuccess, onClose, derapiToken);
  join.open();

A sample .html file is available to help you get started.

For each vendor that you want to collect end-customer authorization you must pass the name of the stored set of vendor credentials. Follow the instructions in the next section to configure Vendor credentials for use with Join.

$ curl \
  -X POST \
  -H 'Content-Type: application/json' \
  https://api.derapi.com/join/session/start \
  -d '{
    "storeCredentials": true,
    "vendors": [
      {
        "vendor": "enphase",
        "credentials": {
          "credentialsID": "cred-rvu37v4fylnbuznf"
        }
      }
    ]
  }'

For Vendors that don’t require credentials:

$ curl \
  -X POST \
  -H 'Content-Type: application/json' \
  https://api.derapi.com/join/session/start \
  -d '{
    "storeCredentials": true,
    "vendors": [
      {
        "vendor": "solaredge"
      }
    ]
  }'

Derapi will store the end-customer tokens for use in making requests. Query https://api.derapi.com/vendor-credentials to see credentials stored for each vendor.

Vendor Authentication

This section outlines how to use Derapi’s API to manage Vendor credentials and Vendor-specific requirements to enroll and access customer devices.

Managing and Using Vendor and Device Credentials

Below are details on how to store credentials for each vendor and end-customer authorized system. Derapi uses your stored credentials to make vendor API calls.

Once you have implemented Derapi Join for end-user authorization, credentials will be automatically be saved and associated with your Derapi Client ID.

  1. Storing Vendor credentials - Some Vendors, such as Enphase, SMA and Tesla, require credentials for your organization. Below is an example of how to store Enphase Monitoring Developer App credentials.
$ curl \
  -X POST \
  -H 'Content-Type: application/json' \
  https://api.derapi.com/vendor-credentials \
  -d '{
    "name": "my-app",
    "credentials": {
      "vendor": "enphase",
      "type": "developerapp",
      "clientID": "'${ENPHASE_CLIENT_ID}'",
      "clientSecret": "'${ENPHASE_CLIENT_SECRET}'",
      "apiKey": "'${ENPHASE_API_KEY}'"
    }
  }'
{
  "id": "cred-rvu37v4fylnbuznf",
  "name": "my-app",
  "credentials": {
    "vendor": "enphase",
    "type": "developerapp"
  }
}
  1. Using stored Vendor credentials for Join - For vendors that require credentials to use join here is an example of how to start a Join session using store credentials.
$ curl \
  -X POST \
  -H 'Content-Type: application/json' \
  https://api.derapi.com/join/session/start \
  -d '{
    "storeCredentials": true,
    "vendors": [
      {
        "vendor": "enphase",
        "credentials": {
          "credentialsID": "cred-rvu37v4fylnbuznf"
        }
      }
    ]
  }'
  1. Query list of stored credentials - The example below illustrates how to query for the list of stored credentials.
$ curl \
  -X GET \
  https://api.derapi.com/vendor-credentials?vendor=enphase
{
  "vendorCredentials": [
    {
      "id": "cred-rvu37v4fylnbuznf",
      "name": "my-app",
      "credentials": {
        "vendor": "enphase",
        "type": "developerapp"
      }
    }
  ]
}
  1. Using stored credentials to make a request, for example to Sites - Derapi will use your stored credentials when making requests.
$ curl \
  -X GET \
  https://api.derapi.com/sites
{
  "sites": [
    {
      "id": "site-wbkxaezgyuvklnop"
    },
    {
      "id": "site-ykvlw42l763dz7di"
    },
    {
      "id": "site-gyumoznfcfivzmrr"
    }
  ],
  "errors": {},
}

Vendor Requirements

This section outlines individual Vendor requirements to enroll customer devices.

Tesla

Requires an account to enroll customer devices. Create a Tesla API account by following these instructions. Store these credentials using the TeslaAppCredentials credentials object in the https://api.derapi.com/vendor-credentials endpoint.

Join will store an access_token and refresh_token. Tesla third party refresh tokens expire after 3 months but Derapi will automatically refresh.

Solis

Solis does not require developers to create an account to enroll devices.

Solis uses a custom authorization system using API ID and Key for each Solis portal account. Join will store these per-account credentials.

SMA

SMA requires an account to enroll customers. To create a SMA API account contact SMA and request credentials for the SMA Code Grant Flow. Also specify api.derapi.com/join/sma/auth-granted as redirect URL in your SMA config request. Store these credentials using the SMAOAuthCredentials credentials object in the https://api.derapi.com/vendor-credentials endpoint.

Join will store a per-system access_token and refresh_token and Derapi will automatically refresh.

SolarEdge

SolarEdge does not require developers to create an account to enroll devices.

SolarEdge uses a custom authorization system using an API Key. This key is retrieved from the SolarEdge Monitoring Portal. Join stores these per-account credentials.

Enphase Monitoring

Enphase requires an account to enroll customers and offers two options for enrolling and authorizing customer systems:

Enphase Developer account

Follow the Enphase instructions to get an access_token and API Key. Store these credentials using the EnphasePartnerAppCredentials credentials object in the https://api.derapi.com/vendor-credentials endpoint.

Join will store an access_token and refresh_token. Enphase access tokens expire after 1 day and refresh tokens expire after 1 month but Derapi will automatically refresh.

Enphase Installer / Partner account

Follow Enphase instructions to get an access_token and API Key. Store these credentials using the EnphaseDeveloperAppCredentials credentials object in the https://api.derapi.com/vendor-credentials endpoint.

Enphase Grid Services

Enphase Grid Services requires a distinct authorization from that of Enphase Monitoring. Enphase Grid Services offers OAuth2 for enrolling customers. Upon request, Derapi will activate your Enphase Grid Services account and store the required credentials associated with your Client ID.

Derapi Join is required to enroll customers for Enphase Grid Services. Query the https://api.derapi.com/vendor-credentials endpoint for the vendor enphasevpp to find the reference to your EnphaseVPPCredentials.