Overview
CLARA exposes a JSON API alongside its web interface. All endpoints are available at https://clarascore.app and return application/json responses.
File upload endpoints use multipart/form-data. Accepted input formats: MusicXML (.mxl, .xml, .musicxml), MIDI (.mid), and ABC notation (.abc).
Error responses include an "error" field with a human-readable message and an appropriate HTTP status code (400 for bad input, 404 for not found, 500 for processing failures).
Maximum upload size: 16 MB.
Read-Only Endpoints
GET
/api/health
/api/health
Health check endpoint. Returns the application status and version.
Parameters
None
Response
{
"status": "ok",
"version": "1.0"
}
GET
/api/styles
/api/styles
Returns all 16 arrangement styles with their names, descriptions, and available sub-variants.
Parameters
None
Response
{
"hymn-block": {
"name": "Hymn Block",
"description": "Classic four-part hymn texture...",
"variants": {
"modern": {
"name": "Modern",
"description": "Contemporary voicings..."
}
}
},
"gospel": { ... },
"bach-chorale": { ... }
}
GET
/api/ensembles
/api/ensembles
Returns all available ensemble types for orchestration, with names, instrument parts, and descriptions.
Parameters
None
Response
{
"quartet": {
"name": "String Quartet",
"parts": "Violin I, Violin II, Viola, Cello",
"description": "The classic chamber ensemble..."
},
"trio": { ... },
"piano-trio": { ... },
"wind-quintet": { ... },
"brass-quintet": { ... },
"custom": { ... }
}
GET
/api/orchestrate-styles
/api/orchestrate-styles
Returns orchestration style details including name, description, features list, and suggested tempo.
Parameters
None
Response
{
"baroque": {
"name": "Baroque",
"description": "Contrapuntal lines, terraced dynamics...",
"features": ["Detache articulation", "Trills & mordents", ...],
"tempo": "Andante"
},
"classical": { ... },
"romantic": { ... },
"impressionist": { ... }
}
GET
/api/samples
/api/samples
Returns the library of built-in sample scores. These are public domain melodies you can use for testing without uploading your own files.
Query Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| category | string | No | Filter by category: choral, vocal, instrumental |
Example
GET /api/samples?category=choral
Response
[
{
"id": "amazing-grace",
"title": "Amazing Grace",
"composer": "Traditional",
"category": "choral",
"suggested_style": "hymn-block"
},
...
]
GET
/api/samples/<id>/file
/api/samples/<id>/file
Download a sample score as a MusicXML file. The id comes from the /api/samples listing.
URL Parameters
| Name | Type | Description |
|---|---|---|
| id | string | Sample score ID (e.g. amazing-grace) |
Response
Binary MusicXML file download (.mxl). On error, returns JSON with an "error" field.
Example
GET /api/samples/amazing-grace/file
GET
/api/style-demo/<style_key>
/api/style-demo/<style_key>
Generates and returns a demo MIDI file (base64-encoded) for a given arrangement style. Used by the Styles page for audio previews. Results are cached on the server.
URL Parameters
| Name | Type | Description |
|---|---|---|
| style_key | string | Style identifier (e.g. gospel, hymn-block) |
Query Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| variant | string | No | Sub-variant to demo (e.g. modern) |
Response
{
"midi_b64": "TVRoZAAAAAYAAQAC..."
}
Processing Endpoints
POST
/api/arrange
/api/arrange
Generate a piano accompaniment from an uploaded melody. Returns download URLs for the arranged score and MIDI.
Content Type
multipart/form-data
Form Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| file | file | Yes | Score file (.mxl, .xml, .musicxml, .mid, .abc) |
| style | string | No | Arrangement style (default: hymn-block). See /api/styles |
| variant | string | No | Style sub-variant (e.g. modern, traditional) |
| intro | string | No | Add intro: on to enable |
| coda | string | No | Add coda: on to enable |
| descant | string | No | Add soprano descant on final phrase: on to enable |
| combined | string | No | Include melody with accompaniment: on to enable |
| modulate | integer | No | Semitones to modulate up for final phrase (e.g. 2) |
| target_key | string | No | Transpose to this key before arranging (e.g. G, Bb, f# minor) |
Example (curl)
curl -X POST https://clarascore.app/api/arrange \
-F "file=@melody.mxl" \
-F "style=gospel" \
-F "intro=on" \
-F "target_key=G"
Response
{
"job_id": "a1b2c3d4",
"style": "gospel",
"original_name": "melody.mxl",
"download_url": "/download/a1b2c3d4/melody_gospel_arranged.mxl",
"midi_url": "/midi/a1b2c3d4/melody_gospel_arranged.mxl"
}
POST
/api/orchestrate
/api/orchestrate
Orchestrate a piano score for a chamber ensemble. Returns download URLs for the ensemble score and MIDI.
Content Type
multipart/form-data
Form Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| file | file | Yes | Piano score file (.mxl, .xml, .musicxml, .mid, .abc) |
| style | string | No | Orchestration style (default: classical). Options: baroque, classical, romantic, impressionist, cinematic, bartok, messiaen |
| ensemble | string | No | Ensemble type (default: quartet). Options: quartet, trio, piano-trio, wind-quintet, brass-quintet, handbells |
| bell_size | string | No | Handbell set size (only for handbells ensemble, default: 3oct) |
Example (curl)
curl -X POST https://clarascore.app/api/orchestrate \
-F "file=@piano-score.mxl" \
-F "style=romantic" \
-F "ensemble=wind-quintet"
Response
{
"job_id": "e5f6g7h8",
"style": "romantic",
"ensemble": "wind-quintet",
"ensemble_name": "Wind Quintet",
"original_name": "piano-score.mxl",
"download_url": "/download/e5f6g7h8/piano-score_romantic_wind5.mxl",
"midi_url": "/midi/e5f6g7h8/piano-score_romantic_wind5.mxl"
}
POST
/api/harmonize
/api/harmonize
Generate SATB or SAB vocal harmonization from a single melody line. Returns download URLs for the harmonized score and MIDI.
Content Type
multipart/form-data
Form Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| file | file | Yes | Melody file (.mxl, .xml, .musicxml, .mid, .abc) |
| voices | string | No | Voice arrangement (default: satb). Options: satb, sab |
| layout | string | No | Score layout (default: open). Options: open, closed |
| voicing | string | No | Voicing style (default: full) |
| target_key | string | No | Transpose to this key before harmonizing (e.g. G, Eb) |
Example (curl)
curl -X POST https://clarascore.app/api/harmonize \
-F "file=@melody.mxl" \
-F "voices=satb" \
-F "target_key=Eb"
Response
{
"job_id": "i9j0k1l2",
"voices": "satb",
"target_key": "Eb",
"original_name": "melody.mxl",
"download_url": "/download/i9j0k1l2/melody_satb_harmonized.mxl",
"midi_url": "/midi/i9j0k1l2/melody_satb_harmonized.mxl"
}
POST
/api/recommend-styles
/api/recommend-styles
Upload a score and get style recommendations based on its key, tempo, meter, and note density. Returns up to 5 suggestions ranked by fit score.
Content Type
multipart/form-data
Form Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| file | file | Yes | Score file to analyze (.mxl, .xml, .musicxml, .mid, .abc) |
Example (curl)
curl -X POST https://clarascore.app/api/recommend-styles \
-F "file=@melody.mxl"
Response
{
"key": "G major",
"mode": "major",
"time_signature": "4/4",
"tempo_bpm": 100,
"measures": 16,
"density": 4.5,
"recommendations": [
{
"style": "hymn-block",
"reason": "Simple meter, short form — classic hymn texture",
"score": 90
},
{
"style": "gospel",
"reason": "Major key, 4/4 time — natural gospel feel",
"score": 85
}
]
}
POST
/api/hymn-setting/analyze
/api/hymn-setting/analyze
Analyze lyrics to detect their poetic meter and return matching hymn tunes from a library of 74 public domain melodies.
Content Type
application/json
JSON Body
| Name | Type | Required | Description |
|---|---|---|---|
| text | string | Yes | Lyrics text (multiple lines, one verse) |
Example (curl)
curl -X POST https://clarascore.app/api/hymn-setting/analyze \
-H "Content-Type: application/json" \
-d '{"text": "Amazing grace how sweet the sound\nThat saved a wretch like me"}'
Response
Returns detected meter, syllable counts, and an array of matching tunes with their names, meters, and keys.
Error Handling
All error responses are JSON objects with an "error" string field:
{
"error": "No file uploaded."
}
HTTP Status Codes
| Code | Meaning |
|---|---|
| 200 | Success |
| 400 | Bad request (missing file, invalid parameters, unsupported format) |
| 404 | Resource not found (unknown sample ID, unknown style) |
| 413 | File too large (exceeds 16 MB limit) |
| 500 | Internal processing error (arrangement/orchestration/analysis failed) |