OpenSubsonic Python API Docs | dltHub

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

Last updated:

OpenSubsonic API allows developers to build programs that interact with compatible servers, supporting both XML and JSON responses. The REST API base URL is http://your-server/rest and Authentication can be performed using an API key or a combination of username and a salted token (or password for older versions)..

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 OpenSubsonic data in under 10 minutes.


What data can I load from OpenSubsonic?

Here are some of the endpoints you can load from OpenSubsonic:

ResourceEndpointMethodData selectorDescription
ping/rest/ping.viewGETPing the server to test connectivity.
get_license/rest/getLicense.viewGETlicenseGet details about the Subsonic license.
get_music_folders/rest/getMusicFolders.viewGETmusicFoldersGet all configured music folders.
get_indexes/rest/getIndexes.viewGETindexesGet an index of all artists.
get_artists/rest/getArtists.viewGETartistsGet all artists.
get_album_list/rest/getAlbumList.viewGETalbumListGet a list of albums.
get_album_list2/rest/getAlbumList2.viewGETalbumList2Get a list of albums (alternative).
get_random_songs/rest/getRandomSongs.viewGETrandomSongsGet a list of random songs.
get_genres/rest/getGenres.viewGETgenresGet all genres.
get_now_playing/rest/getNowPlaying.viewGETnowPlayingGet a list of songs that are currently being played.

How do I authenticate with the OpenSubsonic API?

Authentication is done by providing an apiKey parameter in the request. If an API key is used, the u (username) parameter must not be provided.

1. Get your credentials

The OpenSubsonic API documentation does not provide specific instructions on how to obtain an API key from a provider's dashboard. Users should refer to their specific OpenSubsonic server's administration interface for API key generation.

2. Add them to .dlt/secrets.toml

[sources.open_subsonic_source] api_key = "your_api_key_here"

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 OpenSubsonic 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 open_subsonic_pipeline.py

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

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

Inspect your pipeline and data:

dlt pipeline open_subsonic_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 get_artists and get_album_list from the OpenSubsonic 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 open_subsonic_source(api_key=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "http://your-server/rest", "auth": { "type": "api_key", "api_key": api_key, }, }, "resources": [ {"name": "get_artists", "endpoint": {"path": "getArtists.view", "data_selector": "artists"}}, {"name": "get_album_list", "endpoint": {"path": "getAlbumList.view", "data_selector": "albumList"}} ], } yield from rest_api_resources(config) def get_data() -> None: pipeline = dlt.pipeline( pipeline_name="open_subsonic_pipeline", destination="duckdb", dataset_name="open_subsonic_data", ) load_info = pipeline.run(open_subsonic_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("open_subsonic_pipeline").dataset() sessions_df = data.get_artists.df() print(sessions_df.head())

SQL (DuckDB example):

SELECT * FROM open_subsonic_data.get_artists LIMIT 10;

In a marimo or Jupyter notebook:

import dlt data = dlt.pipeline("open_subsonic_pipeline").dataset() data.get_artists.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 OpenSubsonic 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

API Error Codes

The OpenSubsonic API returns specific error codes within the subsonic-response object when a method fails. The status attribute will be failed, and an error element will contain a code and message.

CodeDescription
0A generic error.
10Required parameter is missing.
20Incompatible Subsonic REST protocol version. Client must upgrade.
30Incompatible Subsonic REST protocol version. Server must upgrade.
40Wrong username or password.
41Token authentication not supported for LDAP users.
42Provided authentication mechanism not supported.
43Multiple conflicting authentication mechanisms provided.
44Invalid API key.
50User is not authorized for the given operation.
60The trial period for the Subsonic server is over. Please upgrade to Subsonic Premium. Visit subsonic.org for details.
70The requested data was not found.

Authentication Failures

Authentication can fail due to incorrect credentials or unsupported authentication mechanisms. Ensure that if an apiKey is provided, the u (username) parameter is not included. If using token-based authentication, verify that the token is correctly calculated as md5(password + salt) and that both t (token) and s (salt) parameters are provided.

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 OpenSubsonic?

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