Detect Programming Languages from Source Code
No API key needed · no rate limits · no sign-up
Detection runs against the live API.
Run to see the result.
Coverage
Supports 54 Languages
Reference
The API in 30 seconds
Base URL https://api.langhint.com. Send the raw source code as the request body, get JSON back. No authentication required; CORS is open, so you can call it from the browser.
POST /detect Classify a snippet
Classify a source code string and return the most likely language plus alternatives.
Request body
The raw source code (Content-Type: text/plain) required — must be non-empty. No JSON wrapper, no escaping.
Query parameters
NameTypeDescription
max_candidates number optional
Maximum number of candidates to return, 1–10. Defaults to 3.
Request
curl -X POST "https://api.langhint.com/detect?max_candidates=3" \ --data-binary 'SELECT id, name FROM users WHERE active = 1'
curl -X POST "https://api.langhint.com/detect?max_candidates=3" \ --data-binary @main.py
Example response
{
"language": "sql", // most likely language (lowercase id)
"probability": 0.97, // probability of the top result (0–1)
"candidates": [ // up to max_candidates, sorted desc
{ "language": "sql", "probability": 0.97 },
{ "language": "ini", "probability": 0.01 }
]
} Status codes
200Language detected, body as above.
400Request body is empty.
422 Validation failed (e.g. max_candidates out of range).
GET /health Liveness probe
Liveness probe for monitoring and uptime checks. Takes no parameters.
{ "status": "ok" } GET /docs OpenAPI / Swagger
Interactive OpenAPI (Swagger) documentation, auto-generated from the service — open /docs .