Requests
GET: query parameters text, q, or message (first match wins). Encode reserved characters in the query string (for example space as %20).
POST: If Content-Type includes application/json, the body must be a JSON object with text, message, or q (string). Otherwise the entire body is read as raw text (useful for text/plain). Max length 50,000 characters for the extracted string in all cases.
Examples
Same path works for v1 and v2; swap /api/v1/detect or /api/v2/detect.
GET /api/v1/detect?q=こんにちは Authorization: Bearer <workspace_api_key>
POST /api/v1/detect
Authorization: Bearer <workspace_api_key>
Content-Type: application/json
{"message": "Mixed input你好 hello"}POST /api/v1/detect Authorization: Bearer <workspace_api_key> Content-Type: text/plain; charset=utf-8 Plain body text with no JSON wrapper.
SDK-ready snippets
// JavaScript / TypeScript
async function detect(text) {
const res = await fetch("https://sift.nu/api/v2/detect", {
method: "POST",
headers: {
Authorization: "Bearer " + process.env.SIFT_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({ text }),
});
if (!res.ok) throw new Error(await res.text());
return res.json();
}# Python
import os, requests
def detect(text: str):
r = requests.post(
"https://sift.nu/api/v1/detect",
headers={"Authorization": f"Bearer {os.environ['SIFT_API_KEY']}"},
json={"text": text},
timeout=10,
)
r.raise_for_status()
return r.json()Input edge cases
- Missing text returns
400with guidance for GET query and POST JSON formats. - On v2, whitespace-only text returns
400withText is empty. - Text longer than
50,000characters returns413.