Legibility report: map an existing codebase into a language
const url = 'https://api.legesher.io/v1/map';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"files":[{"path":"example","source":"example"}],"include_translations":false,"python_version":"3.10","source_lang":"en","target_lang":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Request Bodyrequired
Section titled “ Request Bodyrequired ”A batch of files to produce the legibility report for.
object
Files to map. A request over the per-request file limit gets 413; map a large repository in batches.
One input file for the map.
object
Report label only, treated as content: echoed back to the caller, never logged, never used to touch the filesystem.
The file’s Python source text.
Also return the translated files (default: report only).
Python grammar version used to select the language packs.
Language the codebase is written in.
Language the report maps the codebase into.
Responses
Section titled “ Responses ”Successful Response
Legibility report: what translating this codebase would look like.
object
Per-file report row.
object
Construct occurrences per category in this file.
object
Caller-supplied label, echoed back verbatim.
English constructs present in the file with no entry in the target language’s pack (they stay English after translation).
Aggregate coverage over the mapped batch.
object
Unique constructs seen across the batch.
Of those, how many the target pack has entries for.
True when mapping went through the English pivot.
Unique English constructs without target-pack entries.
One translated file, when include_translations was requested.
object
Example
{ "python_version": "3.10"}Headers
Section titled “ Headers ”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.
Requests remaining in the current rate window.
Seconds until the rate limit fully resets.
Correlation id for this request: the validated inbound X-Request-ID when one was sent, else a server-minted UUID.
Characters left in the caller’s monthly budget.
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.
Envelope for every error response.
object
Machine-readable code + human message for one error.
object
Machine-readable error code, e.g. ‘validation_error’, ‘unsupported_language’, ‘language_pack_not_found’, ‘payload_too_large’, ‘foundation_unavailable’, ‘invalid_source_code’, ‘internal_error’.
Per-field breakdown (validation errors only).
One request-validation problem, stripped of the submitted input.
object
Dotted location of the offending field.
Human-readable description.
Pydantic error type identifier.
Human-readable explanation.
Example generated
{ "error": { "code": "example", "details": [ { "field": "example", "message": "example", "type": "example" } ], "message": "example" }}Headers
Section titled “ Headers ”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).
Envelope for every error response.
object
Machine-readable code + human message for one error.
object
Machine-readable error code, e.g. ‘validation_error’, ‘unsupported_language’, ‘language_pack_not_found’, ‘payload_too_large’, ‘foundation_unavailable’, ‘invalid_source_code’, ‘internal_error’.
Per-field breakdown (validation errors only).
One request-validation problem, stripped of the submitted input.
object
Dotted location of the offending field.
Human-readable description.
Pydantic error type identifier.
Human-readable explanation.
Example generated
{ "error": { "code": "example", "details": [ { "field": "example", "message": "example", "type": "example" } ], "message": "example" }}Headers
Section titled “ Headers ”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.
Requests remaining in the current rate window.
Seconds until the rate limit fully resets.
Correlation id for this request: the validated inbound X-Request-ID when one was sent, else a server-minted UUID.
Characters left in the caller’s monthly budget.
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.
Envelope for every error response.
object
Machine-readable code + human message for one error.
object
Machine-readable error code, e.g. ‘validation_error’, ‘unsupported_language’, ‘language_pack_not_found’, ‘payload_too_large’, ‘foundation_unavailable’, ‘invalid_source_code’, ‘internal_error’.
Per-field breakdown (validation errors only).
One request-validation problem, stripped of the submitted input.
object
Dotted location of the offending field.
Human-readable description.
Pydantic error type identifier.
Human-readable explanation.
Example generated
{ "error": { "code": "example", "details": [ { "field": "example", "message": "example", "type": "example" } ], "message": "example" }}Headers
Section titled “ Headers ”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.
Requests remaining in the current rate window.
Seconds until the rate limit fully resets.
Correlation id for this request: the validated inbound X-Request-ID when one was sent, else a server-minted UUID.
Characters left in the caller’s monthly budget.
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.
Envelope for every error response.
object
Machine-readable code + human message for one error.
object
Machine-readable error code, e.g. ‘validation_error’, ‘unsupported_language’, ‘language_pack_not_found’, ‘payload_too_large’, ‘foundation_unavailable’, ‘invalid_source_code’, ‘internal_error’.
Per-field breakdown (validation errors only).
One request-validation problem, stripped of the submitted input.
object
Dotted location of the offending field.
Human-readable description.
Pydantic error type identifier.
Human-readable explanation.
Example generated
{ "error": { "code": "example", "details": [ { "field": "example", "message": "example", "type": "example" } ], "message": "example" }}Headers
Section titled “ Headers ”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.
Requests remaining in the current rate window.
Seconds until the rate limit fully resets.
Correlation id for this request: the validated inbound X-Request-ID when one was sent, else a server-minted UUID.
Characters left in the caller’s monthly budget.
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.
Envelope for every error response.
object
Machine-readable code + human message for one error.
object
Machine-readable error code, e.g. ‘validation_error’, ‘unsupported_language’, ‘language_pack_not_found’, ‘payload_too_large’, ‘foundation_unavailable’, ‘invalid_source_code’, ‘internal_error’.
Per-field breakdown (validation errors only).
One request-validation problem, stripped of the submitted input.
object
Dotted location of the offending field.
Human-readable description.
Pydantic error type identifier.
Human-readable explanation.
Example generated
{ "error": { "code": "example", "details": [ { "field": "example", "message": "example", "type": "example" } ], "message": "example" }}Headers
Section titled “ Headers ”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.
Requests remaining in the current rate window.
Seconds until the rate limit fully resets.
Correlation id for this request: the validated inbound X-Request-ID when one was sent, else a server-minted UUID.
Characters left in the caller’s monthly budget.
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.
Envelope for every error response.
object
Machine-readable code + human message for one error.
object
Machine-readable error code, e.g. ‘validation_error’, ‘unsupported_language’, ‘language_pack_not_found’, ‘payload_too_large’, ‘foundation_unavailable’, ‘invalid_source_code’, ‘internal_error’.
Per-field breakdown (validation errors only).
One request-validation problem, stripped of the submitted input.
object
Dotted location of the offending field.
Human-readable description.
Pydantic error type identifier.
Human-readable explanation.
Example generated
{ "error": { "code": "example", "details": [ { "field": "example", "message": "example", "type": "example" } ], "message": "example" }}Headers
Section titled “ Headers ”Seconds to wait before retrying. Usually sent with rate_limited; absent on quota_exceeded, which lasts until the UTC month resets.
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.
Requests remaining in the current rate window.
Seconds until the rate limit fully resets.
Correlation id for this request: the validated inbound X-Request-ID when one was sent, else a server-minted UUID.
Characters left in the caller’s monthly budget.
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.
Envelope for every error response.
object
Machine-readable code + human message for one error.
object
Machine-readable error code, e.g. ‘validation_error’, ‘unsupported_language’, ‘language_pack_not_found’, ‘payload_too_large’, ‘foundation_unavailable’, ‘invalid_source_code’, ‘internal_error’.
Per-field breakdown (validation errors only).
One request-validation problem, stripped of the submitted input.
object
Dotted location of the offending field.
Human-readable description.
Pydantic error type identifier.
Human-readable explanation.
Example generated
{ "error": { "code": "example", "details": [ { "field": "example", "message": "example", "type": "example" } ], "message": "example" }}Headers
Section titled “ Headers ”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.
Requests remaining in the current rate window.
Seconds until the rate limit fully resets.
Correlation id for this request: the validated inbound X-Request-ID when one was sent, else a server-minted UUID.
Characters left in the caller’s monthly budget.
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.