Python client library for Moody's Intelligent Risk Platform (IRP) APIs
Project description
irp-integration
A Python client library for the Moody's Intelligent Risk Platform (IRP) APIs. Built to serve as a foundation for larger Moody's integration projects — use it with Jupyter Notebooks, Azure Functions, or any orchestration layer to build end-to-end risk analysis workflows.
Not all Moody's API functionality is covered yet, but the most common operations are available and the library is actively maintained. Contributions are welcome — feel free to fork and modify to fit your project's needs.
Installation
pip install irp-integration
To include Data Bridge (SQL Server) support:
pip install irp-integration[databridge]
Note: Data Bridge requires Microsoft ODBC Driver 18 for SQL Server to be installed on your system.
Quick Start
from irp_integration import IRPClient
# Requires environment variables (see Configuration below)
client = IRPClient()
# Search EDMs
edms = client.edm.search_edms(filter = f'exposureName = "my_edm"')
# Get portfolios for an EDM
edm = edms[0]
exposure_id = edm['exposureId']
portfolios = client.portfolio.search_portfolios(exposure_id = exposure_id)
# Run analysis on a portfolio
edm_name = edm['exposureName']
portfolio = portfolios[0]
portfolio_name = portfolio['portfolioName']
client.analysis.submit_portfolio_analysis_job(
edm_name=edm_name,
portfolio_name=portfolio_name,
job_name="Readme Analysis",
model_profile_id=4418,
output_profile_id=123,
event_rate_scheme_id=739,
treaty_names=['Working Excess Treaty 1'],
tag_names=['Tag1', 'Tag2']
)
Configuration
The library reads configuration from environment variables:
| Variable | Required | Description |
|---|---|---|
RISK_MODELER_BASE_URL |
Yes | Moody's Risk Modeler API base URL |
RISK_MODELER_API_KEY |
Yes | API authentication key |
RISK_MODELER_RESOURCE_GROUP_ID |
Yes | Resource group ID for your organization |
You can set these in your shell, or use a .env file with python-dotenv:
from dotenv import load_dotenv
load_dotenv()
from irp_integration import IRPClient
client = IRPClient()
Data Bridge Configuration
The Data Bridge module (client.databridge) connects directly to Moody's SQL Server databases via ODBC. It requires separate setup from the REST API.
Prerequisites:
- Install the optional dependency:
pip install irp-integration[databridge] - Install Microsoft ODBC Driver 18 for SQL Server:
- Windows: Download and run the MSI installer from Microsoft
- Linux (Debian/Ubuntu):
sudo apt-get install -y unixodbc-dev && sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 - macOS:
brew install microsoft/mssql-release/msodbcsql18
Environment variables (per connection):
Each named connection uses the prefix MSSQL_{CONNECTION_NAME}_:
| Variable | Required | Description |
|---|---|---|
MSSQL_DATABRIDGE_SERVER |
Yes | Server hostname or IP |
MSSQL_DATABRIDGE_USER |
Yes | SQL Server username |
MSSQL_DATABRIDGE_PASSWORD |
Yes | SQL Server password |
MSSQL_DATABRIDGE_PORT |
No | Port (default: 1433) |
Global settings:
| Variable | Default | Description |
|---|---|---|
MSSQL_DRIVER |
ODBC Driver 18 for SQL Server |
ODBC driver name |
MSSQL_TRUST_CERT |
yes |
Trust server certificate |
MSSQL_TIMEOUT |
30 |
Connection timeout in seconds |
Example:
# .env file
MSSQL_DATABRIDGE_SERVER=databridge.company.com
MSSQL_DATABRIDGE_USER=svc_account
MSSQL_DATABRIDGE_PASSWORD=secretpassword
from irp_integration.databridge import DataBridgeManager
dbm = DataBridgeManager()
# Inline query with parameters
df = dbm.execute_query(
"SELECT * FROM portfolios WHERE value > {{ min_value }}",
params={'min_value': 1000000},
database='DataWarehouse'
)
# Execute SQL script from file
results = dbm.execute_query_from_file(
'C:/sql/extract_policies.sql',
params={'cycle_name': 'Q1-2025'},
database='AnalyticsDB'
)
Features
- Automatic retry with exponential backoff for transient errors (429, 5xx)
- Workflow polling — submit long-running operations and automatically poll to completion
- Batch workflow execution — run multiple workflows in parallel and wait for all to finish
- Structured logging via Python's
loggingmodule for visibility into API calls and workflow progress - Connection pooling via persistent HTTP sessions
- Input validation with descriptive error messages
- Custom exception hierarchy for structured error handling
- S3 upload/download with multipart transfer support
- Data Bridge (SQL Server) — direct SQL execution against Moody's Data Bridge with parameterized queries and file-based scripts
- Type hints on all public methods
Modules
| Manager | Description |
|---|---|
client.edm |
Exposure Data Manager — create, upgrade, duplicate, and delete EDMs |
client.portfolio |
Portfolio CRUD, geocoding, and hazard processing |
client.mri_import |
MRI (CSV) data import workflow — bucket creation, file upload, mapping, and execution |
client.treaty |
Reinsurance treaty creation, LOB assignment, and reference data |
client.analysis |
Risk analysis execution, profiles, event rate schemes, and analysis groups |
client.rdm |
Results Data Mart — export analysis results to RDM |
client.risk_data_job |
Risk data job status tracking |
client.import_job |
Platform import job management (EDM/RDM imports) |
client.export_job |
Platform export job management — status, polling, and result download |
client.databridge |
Data Bridge (SQL Server) — parameterized queries, file-based SQL execution |
client.reference_data |
Tags, currencies, and other reference data lookups |
Error Handling
The library uses a custom exception hierarchy:
from irp_integration.exceptions import (
IRPIntegrationError, # Base exception
IRPAPIError, # HTTP/API errors
IRPValidationError, # Input validation failures
IRPWorkflowError, # Workflow execution failures
IRPReferenceDataError, # Reference data lookup failures
IRPFileError, # File operation failures
IRPJobError, # Job management errors
IRPDataBridgeError, # Data Bridge base error
IRPDataBridgeConnectionError, # SQL Server connection failures
IRPDataBridgeQueryError, # SQL query execution failures
)
API Documentation
For detailed API endpoint documentation, see docs/api.md.
License
This project is licensed under the MIT License — see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file irp_integration-0.2.0.tar.gz.
File metadata
- Download URL: irp_integration-0.2.0.tar.gz
- Upload date:
- Size: 73.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69e22592a6d0137aaf6c7dffe7fd3b65f9ebd8a0958045d81f907fbde7dbaf12
|
|
| MD5 |
3e58a3d2442d48c13f2c106a42cabba9
|
|
| BLAKE2b-256 |
aaf4c5e71d7362e5b0e475deb0ec01175c8949a7fbe94b5dab24c8b860ad6d36
|
Provenance
The following attestation bundles were made for irp_integration-0.2.0.tar.gz:
Publisher:
publish.yml on premiumiq/irp-integration
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
irp_integration-0.2.0.tar.gz -
Subject digest:
69e22592a6d0137aaf6c7dffe7fd3b65f9ebd8a0958045d81f907fbde7dbaf12 - Sigstore transparency entry: 970231488
- Sigstore integration time:
-
Permalink:
premiumiq/irp-integration@9fcbfaa9ed8414bdd548bab0ab67e8e7ab3d82ca -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/premiumiq
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9fcbfaa9ed8414bdd548bab0ab67e8e7ab3d82ca -
Trigger Event:
release
-
Statement type:
File details
Details for the file irp_integration-0.2.0-py3-none-any.whl.
File metadata
- Download URL: irp_integration-0.2.0-py3-none-any.whl
- Upload date:
- Size: 69.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28b617900a0ff1bd0276c6f878cbc0c80ff159a010b08469ae1ad156121c34d2
|
|
| MD5 |
bf22694371744f44565f1496cb308652
|
|
| BLAKE2b-256 |
dfd7bc37c1f70cc575a4f966389cdddbe22a984efb822f5aaa946a804fd97b73
|
Provenance
The following attestation bundles were made for irp_integration-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on premiumiq/irp-integration
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
irp_integration-0.2.0-py3-none-any.whl -
Subject digest:
28b617900a0ff1bd0276c6f878cbc0c80ff159a010b08469ae1ad156121c34d2 - Sigstore transparency entry: 970231513
- Sigstore integration time:
-
Permalink:
premiumiq/irp-integration@9fcbfaa9ed8414bdd548bab0ab67e8e7ab3d82ca -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/premiumiq
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9fcbfaa9ed8414bdd548bab0ab67e8e7ab3d82ca -
Trigger Event:
release
-
Statement type: