Code Language Detect API - Identify Source Language
Scores a snippet against language-specific syntactic patterns (keywords, operators, common library calls) and returns the top match with a 0-1 confidence plus up to 3 alternative candidates. Supports javascript, typescript, python, go, rust, java, ruby, php, sql, html, css.
Code examples
curl -X POST https://api.botoi.com/v1/code/detect \
-H "Content-Type: application/json" \
-d '{"code":"const fetchUser = async (id) => {\n const res = await fetch(`/users/${id}`);\n return res.json();\n};"}'When to use this API
Auto-highlight code in chat or comment threads
When a user pastes code into a support ticket or Slack channel, detect the language and apply the matching highlighter theme automatically. Saves the user from typing ```python each time.
Route ingested snippets by language
In a code-search product, classify each incoming file and route JavaScript through one parsing pipeline and Python through another. Improves indexing accuracy when file extensions are missing or wrong.
Fingerprint LLM-generated code
When LLM responses include code blocks without fences, detect the language before sending it to /v1/code/format. Avoids running a JavaScript formatter on Python code.
Frequently asked questions
Which languages are supported?
How does TypeScript versus JavaScript detection work?
What does confidence mean?
How much code do I need to send?
Does this handle mixed-content files?
Get your API key
Free tier includes 5 requests per minute with no credit card required. Upgrade for higher limits.