This project is a little web app to show the basics of using the SolarNetwork API in a TypeScript
project to download large sets of datum stream data using the DatumLoader helper class.
You can see the example in action here:
https://go.solarnetwork.net/dev/example/typescript-datum-loader/
There are a few key aspects of this example worth pointing out.
The solarnetwork-api-core package is included in the project, which provides helpful utilities in both TypeScript and JavaScript for querying datum streams with the SolarNetwork API.
{
"dependencies": {
"solarnetwork-api-core": "^3.1.2"
}
}The example demonstrates using the SolarNetwork token authentication
support included with the solarnetwork-datum-loader library.
First the demo imports the AuthorizationV2Builder class and
creates a reusable instance in an auth variable:
import { AuthorizationV2Builder } from "solarnetwork-api-core/net";
const auth = new AuthorizationV2Builder();A change form event handler listens for changes to the form's token and secret fields, and
saves the credentials for future API calls:
// save credentials
auth.tokenId = settingsForm.snToken.value;
auth.saveSigningKey(settingsForm.snTokenSecret.value);To build yourself, clone or download this repository. You need to have Node 20+ installed. Then:
# initialize dependencies
npm ci
# run development live server on http://localhost:8080
npm run dev
# build for production
npm run buildRunning the build script will generate the application into the dist/ directory.
