Musoni Services Python API Docs | dltHub

Build a Musoni Services-to-database pipeline in Python using dlt with AI Workbench support for Claude Code, Cursor, and Codex.

Last updated:

Musoni Services is a secure, multi‑tenanted microfinance platform exposing a REST API for programmatic access to clients, accounts, transactions, reporting and administrative resources. The REST API base URL is {protocol}://{server}:{port}/api/v1 (examples: https://dev.irl.musoniservices.com:8443/api/v1 and production‑style endpoints documented under developer.musoniservices.com/demo) and All requests require credentials; Musoni supports HTTP Basic authentication plus an x-api-key header and tenant header for multi‑tenant requests..

dlt is an open-source Python library that handles authentication, pagination, and schema evolution automatically. dlthub provides AI context files that enable code assistants to generate production-ready pipelines. Install with uv pip install "dlt[workspace]" and start loading Musoni Services data in under 10 minutes.


What data can I load from Musoni Services?

Here are some of the endpoints you can load from Musoni Services:

ResourceEndpointMethodData selectorDescription
clientsclientsGETList/search clients
client_addressesclient/{id}/addressesGETAddresses for a client
groups_accountsgroups/{id}/accountsGETAccounts summary for a group (loan/savings/share arrays in response)
collectionsheetcollectionsheetGETCollection sheet records (non-paged)
templatestemplatesGETDocument templates list
journalentriesjournalentriesGETRetrieve journal entries (supports many filters)
dataexportsdataexportsGETList data exports
reports_preparedreports/prepared/{id}GETobject / prepared report fieldsFetch prepared report by id
hookshooksGETWebhooks list
searchsearchGETGeneric search endpoint returning array of records

How do I authenticate with the Musoni Services API?

Authenticate via POST /authentication with username/password to receive authenticated metadata including a base64EncodedAuthenticationKey. Most API calls use HTTP Basic auth (username/password) and require headers: X-Fineract-Platform-TenantId: <tenant_identifier> and x-api-key: <api_key> where provided.

1. Get your credentials

  1. Request an api-key from the Musoni Service Desk (contact via Musoni support). 2) Obtain/confirm your Musoni username and password and tenant identifier from the Musoni administrator or provisioning email. 3) Call POST /authentication on your Musoni instance to validate credentials and obtain authentication metadata. 4) Save username/password (for HTTP Basic) and x-api-key plus X-Fineract-Platform-TenantId for API requests.

2. Add them to .dlt/secrets.toml

[sources.musoni_services_source] musoni_username = "your_username" musoni_password = "your_password" musoni_tenant = "your_tenant_identifier" musoni_api_key = "your_x_api_key"

dlt reads this automatically at runtime — never hardcode tokens in your pipeline script. For production environments, see setting up credentials with dlt for environment variable and vault-based options.


How do I set up and run the pipeline?

Set up a virtual environment and install dlt:

uv venv && source .venv/bin/activate uv pip install "dlt[workspace]"

1. Install the dlt AI Workbench:

dlt ai init --agent <your-agent> # <agent>: claude | cursor | codex

This installs project rules, a secrets management skill, appropriate ignore files, and configures the dlt MCP server for your agent. Learn more →

2. Install the rest-api-pipeline toolkit:

dlt ai toolkit rest-api-pipeline install

This loads the skills and context about dlt the agent uses to build the pipeline iteratively, efficiently, and safely. The agent uses MCP tools to inspect credentials — it never needs to read your secrets.toml directly. Learn more →

3. Start LLM-assisted coding:

Use /find-source to load data from the Musoni Services API into DuckDB.

The rest-api-pipeline toolkit takes over from here — it reads relevant API documentation, presents you with options for which endpoints to load, and follows a structured workflow to scaffold, debug, and validate the pipeline step by step.

4. Run the pipeline:

python musoni_services_pipeline.py

If everything is configured correctly, you'll see output like this:

Pipeline musoni_services_pipeline load step completed in 0.26 seconds 1 load package(s) were loaded to destination duckdb and into dataset musoni_services_data The duckdb destination used duckdb:/musoni_services.duckdb location to store data Load package 1749667187.541553 is LOADED and contains no failed jobs

Inspect your pipeline and data:

dlt pipeline musoni_services_pipeline show

This opens the Pipeline Dashboard where you can verify pipeline state, load metrics, schema (tables, columns, types), and query the loaded data directly.


Python pipeline example

This example loads clients and journalentries from the Musoni Services API into DuckDB. It mirrors the endpoint and data selector configuration from the table above:

import dlt from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources @dlt.source def musoni_services_source(musoni_api_key=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "{protocol}://{server}:{port}/api/v1 (examples: https://dev.irl.musoniservices.com:8443/api/v1 and production‑style endpoints documented under developer.musoniservices.com/demo)", "auth": { "type": "http_basic", "api_key": musoni_api_key, }, }, "resources": [ {"name": "clients", "endpoint": {"path": "clients"}}, {"name": "journalentries", "endpoint": {"path": "journalentries"}} ], } yield from rest_api_resources(config) def get_data() -> None: pipeline = dlt.pipeline( pipeline_name="musoni_services_pipeline", destination="duckdb", dataset_name="musoni_services_data", ) load_info = pipeline.run(musoni_services_source()) print(load_info)

To add more endpoints, append entries from the resource table to the "resources" list using the same name, path, and data_selector pattern.


How do I query the loaded data?

Once the pipeline runs, dlt creates one table per resource. You can query with Python or SQL.

Python (pandas DataFrame):

import dlt data = dlt.pipeline("musoni_services_pipeline").dataset() sessions_df = data.clients.df() print(sessions_df.head())

SQL (DuckDB example):

SELECT * FROM musoni_services_data.clients LIMIT 10;

In a marimo or Jupyter notebook:

import dlt data = dlt.pipeline("musoni_services_pipeline").dataset() data.clients.df().head()

See how to explore your data in marimo Notebooks and how to query your data in Python with dataset.


What destinations can I load Musoni Services data to?

dlt supports loading into any of these destinations — only the destination parameter changes:

DestinationExample value
DuckDB (local, default)"duckdb"
PostgreSQL"postgres"
BigQuery"bigquery"
Snowflake"snowflake"
Redshift"redshift"
Databricks"databricks"
Filesystem (S3, GCS, Azure)"filesystem"

Change the destination in dlt.pipeline(destination="snowflake") and add credentials in .dlt/secrets.toml. See the full destinations list.


Troubleshooting

Authentication failures

If you receive 401 Unauthorized, confirm POST /authentication succeeded and that requests include valid HTTP Basic credentials (username/password). Also verify X-Fineract-Platform-TenantId and x-api-key headers if required. Error sample: {"timestamp":..., "status":401, "error":"Unauthorized", "message":"Full authentication is required to access this resource", "path":"/api/v1/{resourceName}"}.

Pagination and limits

List endpoints support offset and limit query parameters. Default limit is 200; maximum returned without pagination is capped (e.g. 2500). Use offset + limit to page through large result sets. Some endpoints support paged=true plus offset/limit.

Permissions and 403 errors

403 Forbidden indicates the authenticated user lacks permissions or data scoping for the requested resource. Use an account with adequate role/office scope.

Common server errors

400 Bad Request for validation issues, 404 Not Found when specific resource ids are missing, 500 Internal Server Error for unexpected failures. Check request parameters and payloads; review error response fields (status, error, message, path).

Ensure that the API key is valid to avoid 401 Unauthorized errors. Also, verify endpoint paths and parameters to avoid 404 Not Found errors.


Next steps

Continue your data engineering journey with the other toolkits of the dltHub AI Workbench:

  • data-exploration — Build custom notebooks, charts, and dashboards for deeper analysis with marimo notebooks.
  • dlthub-runtime — Deploy, schedule, and monitor your pipeline in production.
dlt ai toolkit data-exploration install dlt ai toolkit dlthub-runtime install

Was this page helpful?

Community Hub

Need more dlt context for Musoni Services?

Request dlt skills, commands, AGENT.md files, and AI-native context.