Custom Connector

Swedish Energy Agency Statistics

Sweden

The Swedish Energy Agency Statistics Connector is a specialized middleware service providing streamlined access to Sweden’s official energy statistics. It enables users to discover and explore statistical databases containing critical energy data — from consumption patterns to production figures — browsing tables, retrieving metadata, and executing queries without exposing backend complexity.

Type
Virtual machines, Single VM, BYOL
Runs on
Google Compute Engine
Last update
24 Oct 2024
Category
Integration
Overview

Integration Overview

This document covers the connector’s architecture, configuration, and endpoints. It supports HTTP GET and POST with automatic header propagation, parameter forwarding, and secure API-key management via environment variables.

  • list_databases. Retrieves a list of available databases from the Energy API.
  • list_tables. Retrieves a list of tables within a specified database.
  • get_table_metadata. Retrieves metadata for a specific table within a database.
  • query_table. Executes queries against a specific table using POST requests.
Documentation

Detailed Integration Documentation

Environment Configuration

PurposeConfigures the connector with essential environment variables for API endpoints, ports, and authentication — flexible deployment without code changes.
ParametersRequired:
CONNECTOR_ENV_ENERGY_BASE_URL (base URL); CONNECTOR_ENV_PORT (Flask port, e.g. 8081). Optional:
CONNECTOR_ENV_ENERGY_API_KEY.
BehaviorThe app reads configuration at startup; endpoints are configured with the specified base URL and port.
Workflow exampleSet environment variables in the deployment environment; the application configures endpoints automatically.

Request Forwarding Infrastructure

Core functionsforward_get() and forward_post()
PurposeForwards HTTP requests to the target API, managing headers, parameters, API-key injection, and response handling.
Parametersforward_get:
path (required); headers; params. forward_post:
path (required); headers; json_data.
AuthenticationAutomatically injects the API key from CONNECTOR_ENV_ENERGY_API_KEY into headers (Ocp-Apim-Subscription-Key) and query parameters (subscription-key).
OutputSuccessful: a Flask Response with original content, status code, and Content-Type. Failure: propagates the target API’s error response. (Note: SSL verification is disabled for debugging — enable in production.)

Database Listing

Actionlist_databases
EndpointGET /api/v1/en/
PurposeRetrieves a list of available databases from the Energy API — the primary entry point for discovering data sources.
ParametersQuery:
subscription-key. Headers:
Accept (default application/json).
OutputSuccessful: JSON with the database list. Failure: error response with status code from the Energy API.
Workflow exampleSend GET /api/v1/en/; the connector forwards with authentication and returns the response.

Table Listing

Actionlist_tables
EndpointGET /api/v1/en/{database}
PurposeRetrieves a list of tables within a specified database for data discovery.
ParametersPath:
database (required). Query:
subscription-key. Headers:
Accept.
OutputSuccessful: JSON with the table list. Failure: error for invalid database or authentication issues.
Workflow exampleGET /api/v1/en/energy_db; the connector forwards to the Energy API and returns the table list.

Table Metadata

Actionget_table_metadata
EndpointGET /api/v1/en/{database}/{table}
PurposeRetrieves detailed metadata for a table — columns, data types, and structure.
ParametersPath:
database (required); table (required). Query:
subscription-key. Headers:
Accept.
OutputSuccessful: JSON with the table schema and metadata. Failure: error for invalid table or access restrictions.
Workflow exampleGET /api/v1/en/energy_consumption/household_usage to analyze columns for query planning.

Table Query Execution

Actionquery_table
EndpointPOST /api/v1/en/{database}/{table}
PurposeExecutes queries against a table using POST with a JSON payload for filters and parameters.
ParametersPath:
database (required); table (required). Headers:
Content-Type (default application/json), Accept. Body:
JSON payload with query parameters and filters.
OutputSuccessful: JSON results from the Energy API query. Failure: error response with query execution details.
Workflow examplePOST a JSON payload to /api/v1/en/energy_consumption/household_usage with filters, sorting, and aggregation.

Example Workflow: Energy Statistics Integration

Discover sourcesUse list_databases to fetch available databases (e.g. energy_consumption).
Explore structureUse list_tables with database=energy_consumption to review available tables.
Understand schemaUse get_table_metadata for a table to analyze columns and data types.
Query & integrateUse query_table with a JSON payload, then connect BI tools and automate reporting pipelines.
Support

For technical support, contact custom-connectors-support@isolutions.sa.

free consultation

Schedule a Free Consultation With Our Specialists

Book a free demo
request

Begin Your Adventure With Experienced Professionals

Send request
help desk

Do You Have Questions or Want More Information? Call Now.

Contact support