You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

engrate-sdk

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

engrate-sdk

Engrate SDK for plugin developers

0.0.17
pipPyPI
Maintainers
2

Engrate SDK

A utility SDK providing common services for logging, configuration, and HTTP clients to connect the Engrate Platform.

Features

  • Simple and consistent logging interface
  • Flexible configuration management
  • HTTP client utilities for seamless API integration
  • TypeScript support

Installation

Add the dependency to your project configuration (i.e. UV):

"engrate-sdk ~= 0.0.16"

Then update your local environment

uv pip install .

Usage

from engrate_sdk import Logger, Config, HttpClient

# Logging
logger = Logger()
logger.info('Engrate SDK initialized')

# Configuration
config = Config()
config.load_from_env()

# HTTP Client
client = HttpClient(base_url=config.get('API_URL'))
response = client.get('/status')

Registry

The library contains a regystry.py module which provides access to our internal plugin registry. Every plugin has to call to the register_plugin() method at some point in the plugin bootstrap process (if using ```FastAPI``this is usually recommended to use a lifespan function).

@asynccontextmanager
async def lifespan(fast_app: FastAPI):
    """Startup and shutdown logic using lifespan events."""
    try:
        print("Validating environment variables...")
        env.validate()
        if env.should_register():
            logger.info("Registering plugin...")
            plugin = PluginRegistry(registrar_url=env.get_registrar_url())
            await plugin.register_plugin()
        yield
    finally:
        logger.info("Shutting down application...")

This method will look for a plugin_manifest.yamlfile at root level of the project (it's also possible to provide an url when initializing the PluginRegistryobject) This file must exist and contain the following format (WIP: this might change in the near future):

name: "power-tariffs"
author: "Energy development solutions"
description: "Test plugin to use Engrate SDK"
product_category: "market_intelligence"
extensions:
 markets:
   - "*"
   - "nl"
   - "de"
   - "se"
plugin_metadata:
 display_name: "Demo Plugin"
 service_name: "demo-plugin"
 url_prefix: "demo-plugin"
 fav_icon: ""
 image: ""
 port: "3111"
 api_version: "v1"
 flavors:
   - "external-api"
 traits:
   - "storage"

Mock registrar

For testing purposes, the library includes a mock registrarthat mimics the behaviour for the actual registrar in the core services. This is a simple FastApi server that will implement the required endpoints for puglins lifecycle.

Documentation

[TODO]

License

[TBD]

Keywords

api-client

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.