Statically validate a (possibly translated) source file
const url = 'https://api.legesher.io/v1/validate';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"language":"en","python_version":"3.10","source":"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/validate \ --header 'Content-Type: application/json' \ --data '{ "language": "en", "python_version": "3.10", "source": "example" }'Syntax-check submitted source. compile() only, never executed.
The verdict is produced under the server interpreter’s grammar,
disclosed in the response as grammar_used; python_version selects
the language pack for reverse translation only. If your target version
differs from grammar_used, version-specific constructs may validate
(or fail) against the wrong grammar.
Request Bodyrequired
Section titled “ Request Bodyrequired ”A (possibly translated) Python source file to syntax-check.
object
Language the source is written in (ISO 639 code).
Python grammar version used to select the language pack.
Python source text to validate.
Responses
Section titled “ Responses ”Successful Response
Outcome of a static (compile-only, never-executed) syntax check.
object
CPython grammar version that actually judged the source: the interpreter running the service. When this differs from python_version, a construct that is valid in only one of the two versions can get a verdict that does not transfer to your target version (e.g. PEP 695 type aliases, 3.12+).
The requested version, echoed back. It selects the language pack for reverse translation; it does not select the grammar the syntax verdict is produced under (see grammar_used).
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.
An API key was sent and is not valid. A request with no key runs on the anonymous trial instead.
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.
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.