FreeMusicApi2 SDK
Free Music API client, generated from the OpenAPI spec.
This is an unofficial SDK for the Free Music public API, generated by Voxgig with @voxgig/sdkgen. It is not affiliated with, endorsed by, or sponsored by the upstream API provider.
TypeScript, Python, PHP, Golang, Ruby, Lua SDKs, a CLI, an interactive REPL, and an MCP server for AI agents — all generated from one OpenAPI spec by @voxgig/sdkgen.
Packages
| Language | Package | Install |
|---|---|---|
| TypeScript | @voxgig-sdk/free-music-api2 | publish pending — install from git tag |
| Python | voxgig-sdk-free-music-api2 | publish pending — install from git tag |
| PHP | voxgig-sdk/free-music-api2 | publish pending — install from git tag |
| Golang | github.com/voxgig-sdk/free-music-api2-sdk/go | go get github.com/voxgig-sdk/free-music-api2-sdk/go@latest |
| Ruby | voxgig-sdk-free-music-api2 | publish pending — install from git tag |
| Lua | voxgig-sdk-free-music-api2 | publish pending — install from git tag |
Quickstart
TypeScript
import { FreeMusicApi2SDK } from '@voxgig-sdk/free-music-api2'
const client = new FreeMusicApi2SDK({
apikey: process.env.FREE_MUSIC_API2_APIKEY,
})
// List all v1lists (returns V1List[])
const v1lists = await client.V1List().list()
for (const v1list of v1lists) {
console.log(v1list)
}
See the TypeScript README for the full guide.
Surfaces
| Surface | Path |
|---|---|
| SDK (TypeScript, Python, PHP, Golang, Ruby, Lua) | ts/ py/ php/ go/ rb/ lua/ |
| CLI | go-cli/ |
| MCP server | go-mcp/ |
Use it from an AI agent (MCP)
The generated MCP server exposes every operation in this SDK as an MCP tool that Claude, Cursor or Cline can call directly. Build and register it:
cd go-mcp && go build -o free-music-api2-mcp .
Then add it to your agent’s MCP config (Claude Desktop, Cursor, etc.):
{
"mcpServers": {
"free-music-api2": {
"command": "/abs/path/to/free-music-api2-mcp"
}
}
}
Entities
The API exposes 6 entities:
| Entity | Description | API path |
|---|---|---|
| V1List | The V1List entity (list). | /trending.php |
| V1Lookup | The V1Lookup entity (list). | /track.php |
| V1Search | The V1Search entity (list). | /searchalbum.php |
| V2List | The V2List entity (load). | /list/discography/{artistId} |
| V2Lookup | The V2Lookup entity (load). | /lookup/album/{albumId} |
| V2Search | The V2Search entity (load). | /search/album/{albumName} |
Each entity supports the following operations where available: load, list, create, update, and remove.
Quickstart in other languages
Python
import os
from freemusicapi2_sdk import FreeMusicApi2SDK
client = FreeMusicApi2SDK({
"apikey": os.environ.get("FREE_MUSIC_API2_APIKEY"),
})
# List all v1lists (returns a list, raises on error)
v1lists = client.V1List().list({})
for v1list in v1lists:
print(v1list)
PHP
<?php
require_once 'freemusicapi2_sdk.php';
$client = new FreeMusicApi2SDK([
"apikey" => getenv("FREE_MUSIC_API2_APIKEY"),
]);
// List all v1lists (returns an array; throws on error)
$v1lists = $client->V1List()->list();
print_r($v1lists);
Golang
import sdk "github.com/voxgig-sdk/free-music-api2-sdk/go"
client := sdk.NewFreeMusicApi2SDK(map[string]any{
"apikey": os.Getenv("FREE_MUSIC_API2_APIKEY"),
})
// List all v1lists
v1lists, err := client.V1List(nil).List(nil, nil)
fmt.Println(v1lists)
Ruby
require_relative "FreeMusicApi2_sdk"
client = FreeMusicApi2SDK.new({
"apikey" => ENV["FREE_MUSIC_API2_APIKEY"],
})
# List all v1lists (returns an Array; raises on error)
v1lists = client.V1List.list
puts v1lists
Lua
local sdk = require("free-music-api2_sdk")
local client = sdk.new({
apikey = os.getenv("FREE_MUSIC_API2_APIKEY"),
})
-- List all v1lists
local v1lists, err = client:V1List():list()
print(v1lists)
Unit testing in offline mode
Every SDK ships a test mode that swaps the HTTP transport for an in-memory mock, so unit tests run offline.
TypeScript
const client = FreeMusicApi2SDK.test()
const v1list = await client.V1List().load({ id: 'test01' })
// v1list is a bare V1List populated with mock data
console.log(v1list)
Python
client = FreeMusicApi2SDK.test()
v1list = client.V1List().load({"id": "test01"})
print(v1list)
PHP
// Seed fixture data so offline calls resolve without a live server.
$client = FreeMusicApi2SDK::test([
"entity" => ["v1list" => ["test01" => ["id" => "test01"]]],
]);
$v1list = $client->V1List()->load(["id" => "test01"]);
Golang
client := sdk.Test()
result, err := client.V1List(nil).Load(
map[string]any{"id": "test01"}, nil,
)
Ruby
# Seed fixture data so offline calls resolve without a live server.
client = FreeMusicApi2SDK.test({
"entity" => { "v1list" => { "test01" => { "id" => "test01" } } },
})
v1list = client.V1List.load({ "id" => "test01" })
Lua
local client = sdk.test()
local result, err = client:V1List():load({ id = "test01" })
How it works
Every SDK call runs the same five-stage pipeline:
- Point — resolve the API endpoint from the operation definition.
- Spec — build the HTTP specification (URL, method, headers, body).
- Request — send the HTTP request.
- Response — receive and parse the response.
- Result — extract the result data for the caller.
A feature hook fires at each stage (e.g. PrePoint, PreSpec,
PreRequest), so features can inspect or modify the pipeline without
forking the SDK.
Features
| Feature | Purpose |
|---|---|
| TestFeature | In-memory mock transport for testing without a live server |
Pass custom features via the extend option at construction time.
Direct and Prepare
For endpoints the entity model doesn’t cover, use the low-level methods:
direct(fetchargs)— build and send an HTTP request in one step.prepare(fetchargs)— build the request without sending it.
Both accept a map with path, method, params, query,
headers, and body. See the How-to guides below.
How-to guides
Make a direct API call
When the entity interface does not cover an endpoint, use direct:
TypeScript:
const result = await client.direct({
path: '/api/resource/{id}',
method: 'GET',
params: { id: 'example' },
})
if (result instanceof Error) {
throw result
}
console.log(result.data)
Python:
result = client.direct({
"path": "/api/resource/{id}",
"method": "GET",
"params": {"id": "example"},
})
PHP:
$result = $client->direct([
"path" => "/api/resource/{id}",
"method" => "GET",
"params" => ["id" => "example"],
]);
Go:
result, err := client.Direct(map[string]any{
"path": "/api/resource/{id}",
"method": "GET",
"params": map[string]any{"id": "example"},
})
Ruby:
result = client.direct({
"path" => "/api/resource/{id}",
"method" => "GET",
"params" => { "id" => "example" },
})
Lua:
local result, err = client:direct({
path = "/api/resource/{id}",
method = "GET",
params = { id = "example" },
})
Per-language documentation
Upstream API
This SDK is generated from the upstream OpenAPI specification. It is an unofficial client and is not affiliated with the API provider.
- Upstream API: https://www.theaudiodb.com
Security
Please report security issues to security@voxgig.com. See SECURITY.md. Do not open public issues for suspected vulnerabilities.
Generated from the Free Music API OpenAPI spec by @voxgig/sdkgen.