Code Detection API API

Text Analysis / OAuth Advanced HTTPS
Varies by plan (check documentation)

Overview

Code Detection API automatically identifies programming languages and detects code blocks within plain text or mixed content. It is useful for tools that process user-submitted text and need to highlight or categorize code snippets. Developers can use it to enrich data pipelines or build smarter editors.

💡

Beginner Tip

Use OAuth 2.0 client credentials flow to obtain a Bearer token before calling any endpoint — the token is passed in the Authorization header on every request.

Available Data

Code Detection API data via REST API
JSON-formatted response data
Requires OAuth authentication

Example Response

JSON Response
{
  "status": "success",
  "data": {
    "result": "Data from Code Detection API",
    "description": "Detect, label, format and enrich the code in your app or in your data pipeline",
    "timestamp": "2025-01-15T10:00:00Z"
  }
}

Field Reference

language The detected programming language name (e.g., "Python", "JavaScript")
confidence Confidence score between 0 and 1 indicating how certain the detection is
code_blocks List of extracted code block objects found within the submitted text
formatted_code The detected code reformatted with consistent indentation and style

Implementation Example

const url = "https://codedetectionapi.runtime.dev/";
// Replace headers or query params with the values required by this API.
const response = await fetch(url, {
  headers: {
  "Authorization": "Bearer YOUR_API_KEY"
  }
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

401 Unauthorized Missing or expired Bearer token in the Authorization header
Re-run the OAuth token exchange and include the fresh token as "Authorization: Bearer <token>"
400 Bad Request Request body is not valid JSON or the "text" field is missing
Ensure your payload is properly serialized JSON with the required "text" field
Empty language array in response The submitted text contains no detectable code patterns
Verify the input includes actual code; plain prose will not trigger language detection

Matrix Score Breakdown

🌐 Reachability 30/30
⚡ Speed 5/20
🔒 Security 15/15
🛠 Developer XP 3/20
✓ Reliability 10/15

Partially tested on Apr 5, 2026

Technical Specifications

Auth OAuth
HTTPS REQUIRED
CORS UNKNOWN
Category Text Analysis
Difficulty Advanced
Verified: 2026-04-04

Similar APIs

View All →