# 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):
```code
"engrate-sdk ~= 0.0.16"
```
Then update your local environment
```bash
uv pip install .
```
## Usage
```python
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).
```python
@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.yaml```file at root level of the project (it's also possible to provide an url when initializing the ```PluginRegistry```object) This file must exist and contain the following format ***(WIP: this might change in the near future)***:
```yaml
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 registrar```that 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]
Raw data
{
"_id": null,
"home_page": null,
"name": "engrate-sdk",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "Carlos <carlos@engrate.io>, Joel <joel@engrate.io>, Rille <rille@engrate.io>",
"keywords": "api-client, energy, engrate, http-client, logging, mcp, plugins, sdk",
"author": null,
"author_email": "Engrate Dev <dev@engrate.io>",
"download_url": "https://files.pythonhosted.org/packages/39/8e/c34dafc40ea1e93cc17176a5abdcd09429b12673a190bd1786d6ac598b05/engrate_sdk-0.0.17.tar.gz",
"platform": null,
"description": "# Engrate SDK\n\nA utility SDK providing common services for logging, configuration, and HTTP clients to connect the Engrate Platform.\n\n## Features\n\n- Simple and consistent logging interface\n- Flexible configuration management\n- HTTP client utilities for seamless API integration\n- TypeScript support\n\n## Installation\n\nAdd the dependency to your project configuration (i.e. UV):\n\n```code\n\"engrate-sdk ~= 0.0.16\"\n```\nThen update your local environment\n```bash\nuv pip install .\n```\n\n## Usage\n\n```python\nfrom engrate_sdk import Logger, Config, HttpClient\n\n# Logging\nlogger = Logger()\nlogger.info('Engrate SDK initialized')\n\n# Configuration\nconfig = Config()\nconfig.load_from_env()\n\n# HTTP Client\nclient = HttpClient(base_url=config.get('API_URL'))\nresponse = client.get('/status')\n```\n\n## Registry\n\nThe library contains a ```regystry.py``` module which provides access to our internal plugin registry. Every plugin has to call to the ```register_plugin()``` method\nat some point in the plugin bootstrap process (if using ```FastAPI``this is usually recommended to use a lifespan function). \n\n```python\n@asynccontextmanager\nasync def lifespan(fast_app: FastAPI):\n \"\"\"Startup and shutdown logic using lifespan events.\"\"\"\n try:\n print(\"Validating environment variables...\")\n env.validate()\n if env.should_register():\n logger.info(\"Registering plugin...\")\n plugin = PluginRegistry(registrar_url=env.get_registrar_url())\n await plugin.register_plugin()\n yield\n finally:\n logger.info(\"Shutting down application...\")\n```\nThis method will look for a ```plugin_manifest.yaml```file at root level of the project (it's also possible to provide an url when initializing the ```PluginRegistry```object) This file must exist and contain the following format ***(WIP: this might change in the near future)***:\n\n ```yaml\nname: \"power-tariffs\"\nauthor: \"Energy development solutions\"\ndescription: \"Test plugin to use Engrate SDK\"\nproduct_category: \"market_intelligence\"\nextensions:\n markets:\n - \"*\"\n - \"nl\"\n - \"de\"\n - \"se\"\nplugin_metadata:\n display_name: \"Demo Plugin\"\n service_name: \"demo-plugin\"\n url_prefix: \"demo-plugin\"\n fav_icon: \"\"\n image: \"\"\n port: \"3111\"\n api_version: \"v1\"\n flavors:\n - \"external-api\"\n traits:\n - \"storage\"\n\n ```\n\n### Mock registrar\nFor testing purposes, the library includes a ```mock registrar```that mimics the behaviour for the actual registrar in the core services. This is a simple ```FastApi``` server that will\nimplement the required endpoints for puglins lifecycle.\n\n## Documentation\n\n[TODO]\n\n## License\n\n[TBD]",
"bugtrack_url": null,
"license": "MIT",
"summary": "Engrate SDK for plugin developers",
"version": "0.0.17",
"project_urls": {
"Homepage": "https://engrate.io",
"Repository": "https://github.com/engrate/engrate-sdk"
},
"split_keywords": [
"api-client",
" energy",
" engrate",
" http-client",
" logging",
" mcp",
" plugins",
" sdk"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "d84f2ca346193fbdcdc795ae4369cbe628b44dbf5f33b1adb528f4b84cb36bd9",
"md5": "8ae32282ca49092b3fa52e615d0d7f02",
"sha256": "a5067744abcb8c1ba27df08f986cb5431e382e85e11e4c06aea6efe895bb8a56"
},
"downloads": -1,
"filename": "engrate_sdk-0.0.17-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8ae32282ca49092b3fa52e615d0d7f02",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 13370,
"upload_time": "2025-07-11T11:48:41",
"upload_time_iso_8601": "2025-07-11T11:48:41.493152Z",
"url": "https://files.pythonhosted.org/packages/d8/4f/2ca346193fbdcdc795ae4369cbe628b44dbf5f33b1adb528f4b84cb36bd9/engrate_sdk-0.0.17-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "398ec34dafc40ea1e93cc17176a5abdcd09429b12673a190bd1786d6ac598b05",
"md5": "8efa0ecdc54241186756729aa9d64bac",
"sha256": "e2300a4e2f15918d00f63082727fc8a2fb406e417c2e6f085fe3a838ac9ca9e6"
},
"downloads": -1,
"filename": "engrate_sdk-0.0.17.tar.gz",
"has_sig": false,
"md5_digest": "8efa0ecdc54241186756729aa9d64bac",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 11366,
"upload_time": "2025-07-11T11:48:42",
"upload_time_iso_8601": "2025-07-11T11:48:42.940981Z",
"url": "https://files.pythonhosted.org/packages/39/8e/c34dafc40ea1e93cc17176a5abdcd09429b12673a190bd1786d6ac598b05/engrate_sdk-0.0.17.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-11 11:48:42",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "engrate",
"github_project": "engrate-sdk",
"github_not_found": true,
"lcname": "engrate-sdk"
}