Skip to content

Legibility report: map an existing codebase into a language

POST
/v1/map
curl --request POST \
--url https://api.legesher.io/v1/map \
--header 'Content-Type: application/json' \
--data '{ "files": [ { "path": "example", "source": "example" } ], "include_translations": false, "python_version": "3.10", "source_lang": "en", "target_lang": "example" }'

Per-file translatability + aggregate coverage for a batch of files.

REST parity with the open legesher-mcp package’s map_existing_codebase tool. File paths are report labels only, treated as content: echoed back, never logged, never used to touch the filesystem.

Requires an API key on a paid plan. A caller who is not signed in, or whose plan does not pay, gets 402 entitlement_required: the same answer the hosted MCP instance gives for map_existing_codebase.

Media type application/json
CodebaseMapRequest

A batch of files to produce the legibility report for.

object
files
required
Files

Files to map. A request over the per-request file limit gets 413; map a large repository in batches.

Array<object>
>= 1 items
SourceFile

One input file for the map.

object
path
required
Path

Report label only, treated as content: echoed back to the caller, never logged, never used to touch the filesystem.

string
>= 1 characters <= 1024 characters
source
required
Source

The file’s Python source text.

string
>= 1 characters <= 2000000 characters
include_translations
Include Translations

Also return the translated files (default: report only).

boolean
python_version
Python Version

Python grammar version used to select the language packs.

string
default: 3.13
Allowed values: 3.10 3.11 3.12 3.13 3.14
source_lang
Source Lang

Language the codebase is written in.

string
default: en >= 2 characters <= 16 characters /^[a-z]{2,3}(-[A-Za-z0-9]+)?$/
target_lang
required
Target Lang

Language the report maps the codebase into.

string
>= 2 characters <= 16 characters /^[a-z]{2,3}(-[A-Za-z0-9]+)?$/

Successful Response

Media type application/json
CodebaseMapResponse

Legibility report: what translating this codebase would look like.

object
files
required
Files
Array<object>
FileMapEntry

Per-file report row.

object
construct_counts
Construct Counts

Construct occurrences per category in this file.

object
key
additional properties
integer
issue
Issue

Why the file could not be mapped, if it couldn’t.

Any of:
string
path
required
Path

Caller-supplied label, echoed back verbatim.

string
translatable
required
Translatable
boolean
unmapped_constructs
Unmapped Constructs

English constructs present in the file with no entry in the target language’s pack (they stay English after translation).

Array<string>
python_version
required
Python Version
string
Allowed values: 3.10 3.11 3.12 3.13 3.14
source_lang
required
Source Lang
string
summary
required
CodebaseMapSummary

Aggregate coverage over the mapped batch.

object
constructs_found
required
Constructs Found

Unique constructs seen across the batch.

integer
constructs_mapped
required
Constructs Mapped

Of those, how many the target pack has entries for.

integer
coverage_ratio
required
Coverage Ratio

Constructs_mapped / constructs_found; null when no constructs were found.

Any of:
number
files_total
required
Files Total
integer
files_translatable
required
Files Translatable
integer
pivoted
required
Pivoted

True when mapping went through the English pivot.

boolean
unmapped_constructs
Unmapped Constructs

Unique English constructs without target-pack entries.

Array<string>
target_lang
required
Target Lang
string
translated_files
Translated Files
Any of:
Array<object>
TranslatedFile

One translated file, when include_translations was requested.

object
path
required
Path
string
translated_source
required
Translated Source
string

Example

{
"python_version": "3.10"
}
X-RateLimit-Limit
integer

Requests permitted per minute for the caller’s tier. The X-RateLimit-* set is omitted when the tier’s rate is unlimited, and on a request refused before the caller is identified.

X-RateLimit-Remaining
integer

Requests remaining in the current rate window.

X-RateLimit-Reset
integer

Seconds until the rate limit fully resets.

X-Request-ID
string

Correlation id for this request: the validated inbound X-Request-ID when one was sent, else a server-minted UUID.

X-Usage-Characters-Remaining
integer

Characters left in the caller’s monthly budget.

X-Usage-Characters-Used
integer

Characters billed against the caller’s monthly budget, UTC month to date. The X-Usage-* pair is omitted when the budget is unlimited, and on a request refused before the caller is identified.

The API key sent is not valid.

Media type application/json
ErrorResponse

Envelope for every error response.

object
error
required
ErrorDetail

Machine-readable code + human message for one error.

object
code
required
Code

Machine-readable error code, e.g. ‘validation_error’, ‘unsupported_language’, ‘language_pack_not_found’, ‘payload_too_large’, ‘foundation_unavailable’, ‘invalid_source_code’, ‘internal_error’.

string
details
Details

Per-field breakdown (validation errors only).

Any of:
Array<object>
FieldIssue

One request-validation problem, stripped of the submitted input.

object
field
required
Field

Dotted location of the offending field.

string
message
required
Message

Human-readable description.

string
type
required
Type

Pydantic error type identifier.

string
message
required
Message

Human-readable explanation.

string

Example generated

{
"error": {
"code": "example",
"details": [
{
"field": "example",
"message": "example",
"type": "example"
}
],
"message": "example"
}
}
X-Request-ID
string

Correlation id for this request: the validated inbound X-Request-ID when one was sent, else a server-minted UUID.

No API key was sent, or the key’s plan does not include mapping (entitlement_required).

Media type application/json
ErrorResponse

Envelope for every error response.

object
error
required
ErrorDetail

Machine-readable code + human message for one error.

object
code
required
Code

Machine-readable error code, e.g. ‘validation_error’, ‘unsupported_language’, ‘language_pack_not_found’, ‘payload_too_large’, ‘foundation_unavailable’, ‘invalid_source_code’, ‘internal_error’.

string
details
Details

Per-field breakdown (validation errors only).

Any of:
Array<object>
FieldIssue

One request-validation problem, stripped of the submitted input.

object
field
required
Field

Dotted location of the offending field.

string
message
required
Message

Human-readable description.

string
type
required
Type

Pydantic error type identifier.

string
message
required
Message

Human-readable explanation.

string

Example generated

{
"error": {
"code": "example",
"details": [
{
"field": "example",
"message": "example",
"type": "example"
}
],
"message": "example"
}
}
X-RateLimit-Limit
integer

Requests permitted per minute for the caller’s tier. The X-RateLimit-* set is omitted when the tier’s rate is unlimited, and on a request refused before the caller is identified.

X-RateLimit-Remaining
integer

Requests remaining in the current rate window.

X-RateLimit-Reset
integer

Seconds until the rate limit fully resets.

X-Request-ID
string

Correlation id for this request: the validated inbound X-Request-ID when one was sent, else a server-minted UUID.

X-Usage-Characters-Remaining
integer

Characters left in the caller’s monthly budget.

X-Usage-Characters-Used
integer

Characters billed against the caller’s monthly budget, UTC month to date. The X-Usage-* pair is omitted when the budget is unlimited, and on a request refused before the caller is identified.

The language has no pack for the requested Python version.

Media type application/json
ErrorResponse

Envelope for every error response.

object
error
required
ErrorDetail

Machine-readable code + human message for one error.

object
code
required
Code

Machine-readable error code, e.g. ‘validation_error’, ‘unsupported_language’, ‘language_pack_not_found’, ‘payload_too_large’, ‘foundation_unavailable’, ‘invalid_source_code’, ‘internal_error’.

string
details
Details

Per-field breakdown (validation errors only).

Any of:
Array<object>
FieldIssue

One request-validation problem, stripped of the submitted input.

object
field
required
Field

Dotted location of the offending field.

string
message
required
Message

Human-readable description.

string
type
required
Type

Pydantic error type identifier.

string
message
required
Message

Human-readable explanation.

string

Example generated

{
"error": {
"code": "example",
"details": [
{
"field": "example",
"message": "example",
"type": "example"
}
],
"message": "example"
}
}
X-RateLimit-Limit
integer

Requests permitted per minute for the caller’s tier. The X-RateLimit-* set is omitted when the tier’s rate is unlimited, and on a request refused before the caller is identified.

X-RateLimit-Remaining
integer

Requests remaining in the current rate window.

X-RateLimit-Reset
integer

Seconds until the rate limit fully resets.

X-Request-ID
string

Correlation id for this request: the validated inbound X-Request-ID when one was sent, else a server-minted UUID.

X-Usage-Characters-Remaining
integer

Characters left in the caller’s monthly budget.

X-Usage-Characters-Used
integer

Characters billed against the caller’s monthly budget, UTC month to date. The X-Usage-* pair is omitted when the budget is unlimited, and on a request refused before the caller is identified.

The request body or the source is over the size limit.

Media type application/json
ErrorResponse

Envelope for every error response.

object
error
required
ErrorDetail

Machine-readable code + human message for one error.

object
code
required
Code

Machine-readable error code, e.g. ‘validation_error’, ‘unsupported_language’, ‘language_pack_not_found’, ‘payload_too_large’, ‘foundation_unavailable’, ‘invalid_source_code’, ‘internal_error’.

string
details
Details

Per-field breakdown (validation errors only).

Any of:
Array<object>
FieldIssue

One request-validation problem, stripped of the submitted input.

object
field
required
Field

Dotted location of the offending field.

string
message
required
Message

Human-readable description.

string
type
required
Type

Pydantic error type identifier.

string
message
required
Message

Human-readable explanation.

string

Example generated

{
"error": {
"code": "example",
"details": [
{
"field": "example",
"message": "example",
"type": "example"
}
],
"message": "example"
}
}
X-RateLimit-Limit
integer

Requests permitted per minute for the caller’s tier. The X-RateLimit-* set is omitted when the tier’s rate is unlimited, and on a request refused before the caller is identified.

X-RateLimit-Remaining
integer

Requests remaining in the current rate window.

X-RateLimit-Reset
integer

Seconds until the rate limit fully resets.

X-Request-ID
string

Correlation id for this request: the validated inbound X-Request-ID when one was sent, else a server-minted UUID.

X-Usage-Characters-Remaining
integer

Characters left in the caller’s monthly budget.

X-Usage-Characters-Used
integer

Characters billed against the caller’s monthly budget, UTC month to date. The X-Usage-* pair is omitted when the budget is unlimited, and on a request refused before the caller is identified.

A field is missing or malformed, or a language code is not supported.

Media type application/json
ErrorResponse

Envelope for every error response.

object
error
required
ErrorDetail

Machine-readable code + human message for one error.

object
code
required
Code

Machine-readable error code, e.g. ‘validation_error’, ‘unsupported_language’, ‘language_pack_not_found’, ‘payload_too_large’, ‘foundation_unavailable’, ‘invalid_source_code’, ‘internal_error’.

string
details
Details

Per-field breakdown (validation errors only).

Any of:
Array<object>
FieldIssue

One request-validation problem, stripped of the submitted input.

object
field
required
Field

Dotted location of the offending field.

string
message
required
Message

Human-readable description.

string
type
required
Type

Pydantic error type identifier.

string
message
required
Message

Human-readable explanation.

string

Example generated

{
"error": {
"code": "example",
"details": [
{
"field": "example",
"message": "example",
"type": "example"
}
],
"message": "example"
}
}
X-RateLimit-Limit
integer

Requests permitted per minute for the caller’s tier. The X-RateLimit-* set is omitted when the tier’s rate is unlimited, and on a request refused before the caller is identified.

X-RateLimit-Remaining
integer

Requests remaining in the current rate window.

X-RateLimit-Reset
integer

Seconds until the rate limit fully resets.

X-Request-ID
string

Correlation id for this request: the validated inbound X-Request-ID when one was sent, else a server-minted UUID.

X-Usage-Characters-Remaining
integer

Characters left in the caller’s monthly budget.

X-Usage-Characters-Used
integer

Characters billed against the caller’s monthly budget, UTC month to date. The X-Usage-* pair is omitted when the budget is unlimited, and on a request refused before the caller is identified.

Too many requests, or this month’s character allowance is used up.

Media type application/json
ErrorResponse

Envelope for every error response.

object
error
required
ErrorDetail

Machine-readable code + human message for one error.

object
code
required
Code

Machine-readable error code, e.g. ‘validation_error’, ‘unsupported_language’, ‘language_pack_not_found’, ‘payload_too_large’, ‘foundation_unavailable’, ‘invalid_source_code’, ‘internal_error’.

string
details
Details

Per-field breakdown (validation errors only).

Any of:
Array<object>
FieldIssue

One request-validation problem, stripped of the submitted input.

object
field
required
Field

Dotted location of the offending field.

string
message
required
Message

Human-readable description.

string
type
required
Type

Pydantic error type identifier.

string
message
required
Message

Human-readable explanation.

string

Example generated

{
"error": {
"code": "example",
"details": [
{
"field": "example",
"message": "example",
"type": "example"
}
],
"message": "example"
}
}
Retry-After
integer

Seconds to wait before retrying. Usually sent with rate_limited; absent on quota_exceeded, which lasts until the UTC month resets.

X-RateLimit-Limit
integer

Requests permitted per minute for the caller’s tier. The X-RateLimit-* set is omitted when the tier’s rate is unlimited, and on a request refused before the caller is identified.

X-RateLimit-Remaining
integer

Requests remaining in the current rate window.

X-RateLimit-Reset
integer

Seconds until the rate limit fully resets.

X-Request-ID
string

Correlation id for this request: the validated inbound X-Request-ID when one was sent, else a server-minted UUID.

X-Usage-Characters-Remaining
integer

Characters left in the caller’s monthly budget.

X-Usage-Characters-Used
integer

Characters billed against the caller’s monthly budget, UTC month to date. The X-Usage-* pair is omitted when the budget is unlimited, and on a request refused before the caller is identified.

The translation engine is unavailable.

Media type application/json
ErrorResponse

Envelope for every error response.

object
error
required
ErrorDetail

Machine-readable code + human message for one error.

object
code
required
Code

Machine-readable error code, e.g. ‘validation_error’, ‘unsupported_language’, ‘language_pack_not_found’, ‘payload_too_large’, ‘foundation_unavailable’, ‘invalid_source_code’, ‘internal_error’.

string
details
Details

Per-field breakdown (validation errors only).

Any of:
Array<object>
FieldIssue

One request-validation problem, stripped of the submitted input.

object
field
required
Field

Dotted location of the offending field.

string
message
required
Message

Human-readable description.

string
type
required
Type

Pydantic error type identifier.

string
message
required
Message

Human-readable explanation.

string

Example generated

{
"error": {
"code": "example",
"details": [
{
"field": "example",
"message": "example",
"type": "example"
}
],
"message": "example"
}
}
X-RateLimit-Limit
integer

Requests permitted per minute for the caller’s tier. The X-RateLimit-* set is omitted when the tier’s rate is unlimited, and on a request refused before the caller is identified.

X-RateLimit-Remaining
integer

Requests remaining in the current rate window.

X-RateLimit-Reset
integer

Seconds until the rate limit fully resets.

X-Request-ID
string

Correlation id for this request: the validated inbound X-Request-ID when one was sent, else a server-minted UUID.

X-Usage-Characters-Remaining
integer

Characters left in the caller’s monthly budget.

X-Usage-Characters-Used
integer

Characters billed against the caller’s monthly budget, UTC month to date. The X-Usage-* pair is omitted when the budget is unlimited, and on a request refused before the caller is identified.