Skip to main content
POST
/
v1
/
detect
Detect Language & Dialect
curl --request POST \
  --url https://api.trynawa.com/v1/detect
Detect language, dialect, script, and text direction from any text input. Uses local NAGL modules only — no external AI call, so responses return in under 100ms.
Cost: $0.002 per request (2 credits). Semantic cache hits are free (X-NAWA-Cache: HIT).

Request

Headers

HeaderRequiredDescription
AuthorizationYesBearer nawa_live_sk_xxx or Bearer nawa_test_sk_xxx
Content-TypeYesapplication/json

Body parameters

ParameterTypeRequiredDescription
textstringYesThe text to detect. Max 5,000 characters.

Example request

curl -X POST https://api.trynawa.com/v1/detect \
  -H "Authorization: Bearer nawa_test_sk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"text": "وش رايكم بالمحتوى الجديد؟"}'

Response

Success response (200)

{
  "success": true,
  "result": {
    "id": "det_nw_pon1yom9bkfe",
    "object": "detection",
    "text": "وش رايكم بالمحتوى الجديد؟",
    "language": "ar",
    "dialect": "gulf",
    "dialect_confidence": 0.95,
    "script": "arabic",
    "text_direction": "rtl",
    "word_count": 4,
    "fallback_used": false,
    "cached": false,
    "cost_usd": 0.002,
    "credits_used": 2
  },
  "errors": [],
  "request_id": "req_nw_4c11w71e44cb"
}

Result fields

FieldTypeDescription
textstringThe original input text
languagestringDetected language: ar, en, or mixed
dialectstring or nullDetected Arabic dialect: gulf, egyptian, levantine, msa. Null if not Arabic.
dialect_confidencenumber or nullConfidence score 0—1 for dialect detection. Null if not Arabic.
scriptstringScript type: arabic, latin, or mixed
text_directionstringText direction: rtl or ltr
word_countnumberNumber of words in the input text
fallback_usedbooleanAlways false for this endpoint (local detection only)
cachedbooleanWhether served from semantic cache
cost_usdnumberCost in USD
credits_usednumberCredits deducted

Detection examples

Input: “وش رايكم بالمحتوى الجديد؟” Result: language: ar, dialect: gulf, confidence: 0.95, script: arabic, direction: rtl
curl -X POST https://api.trynawa.com/v1/detect \
  -H "Authorization: Bearer nawa_test_sk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"text": "وش رايكم بالمحتوى الجديد؟"}'
Input: “الفيديو ده جامد أوي” Result: language: ar, dialect: egyptian, script: arabic, direction: rtl
curl -X POST https://api.trynawa.com/v1/detect \
  -H "Authorization: Bearer nawa_test_sk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"text": "الفيديو ده جامد أوي"}'
Input: “This is a great video” Result: language: en, dialect: null, script: latin, direction: ltr
curl -X POST https://api.trynawa.com/v1/detect \
  -H "Authorization: Bearer nawa_test_sk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"text": "This is a great video"}'
Input: “awesome محتوى” Result: language: mixed, dialect detected, script: mixed, direction: rtl
curl -X POST https://api.trynawa.com/v1/detect \
  -H "Authorization: Bearer nawa_test_sk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"text": "awesome محتوى"}'

Error responses

StatusTypeWhen
400invalid_request_errorMissing text. Text too long.
401authentication_errorInvalid or missing API key
402insufficient_creditsNo credits remaining
429rate_limit_errorRate limit exceeded
500api_errorInternal error