API

How to automate SMS code extraction from Unicode or non-Latin characters with SMSVerifier API?

July 30, 2026 · 7 min read · 10 views
SMSVerifier API fully supports receiving SMS messages with Unicode and non-Latin characters, allowing you to automate OTP extraction by fetching the raw message text and applying Unicode-aware parsing techniques in your code.

Understanding Unicode SMS and Non-Latin OTPs

Many online services send OTP (One-Time Password) codes embedded in SMS messages that contain Unicode characters, including non-Latin scripts such as Cyrillic, Arabic, Chinese, Hindi, or emoji. These messages require proper handling to accurately extract the numeric or alphanumeric verification codes.

Important context.

Unicode SMS use UTF-16 or UCS-2 encoding, which enables representation of characters from virtually all human languages and symbols in a single message.

Unlike ASCII-only messages, Unicode SMS can include right-to-left text, complex scripts, or mixed languages, which means naive text parsing methods may fail or misinterpret the content. Automating extraction means your system must reliably identify the OTP code within these diverse text formats.

Accessing Raw SMS Messages with SMSVerifier API

SMSVerifier API provides direct access to the full raw SMS message text as received by our virtual phone numbers. This includes all Unicode characters intact, with no loss of fidelity.

Pro tip.

Always retrieve the sms field from the API response for the full Unicode message before attempting any parsing.

For example, a typical GET request to getStatus action with your API key and order ID returns JSON containing the SMS message:

bash
curl "https://smsverifier.com/stubs/handler_api.php?api_key=YOUR_API_KEY&action=getStatus&id=ORDER_ID"

Response snippet:

json
{
  "status": "STATUS_OK",
  "sms": "Ваш код подтверждения: 123456"
}

This message includes Cyrillic characters alongside a 6-digit OTP. Your automation code will then analyze the sms string to extract 123456.

Parsing OTP Codes from Unicode Text

To reliably extract OTP codes from Unicode SMS messages, consider the following:

  • Normalize text encoding: Ensure your code treats the SMS text as a Unicode string (UTF-8 or UTF-16) to prevent character corruption.
  • Use Unicode-aware regex: Regular expressions need to handle Unicode digits or letters, depending on OTP format. For example, to match digits use the Unicode property \p{Nd} in regex engines that support it.
  • Identify OTP patterns: OTP codes are often numeric sequences of fixed length (4-8 digits) or alphanumeric strings. Locate these by pattern matching, often near keywords like “код”, “code”, “验证码”, or “OTP”.
Common pitfall.

Using ASCII-only regex such as \d might miss digits in some scripts or fail on messages mixing LTR and RTL text.

Example Unicode-aware regex for digit extraction in some languages:

python
import regex as re  # 'regex' module supports Unicode properties
pattern = re.compile(r"\b(\p{Nd}{4,8})\b")
matches = pattern.findall(sms_text)
otp = matches[0] if matches else None

Handling Multi-language and Multi-format OTPs

Because SMSVerifier covers 4000+ services worldwide, OTP message formats vary widely:

  • Some services include the OTP inside phrases like “Your code: 4321” (English)
  • Others send “验证码为:987654” (Chinese)
  • Some include spaces, dashes, or letters mixed in the code

To handle this diversity:

  • Maintain a per-service or per-country pattern dictionary mapping keywords to regexes
  • Leverage natural language processing (NLP) libraries that support multiple scripts to identify keyword contexts
  • Test your extraction logic across languages you target
Parsing OTPs from Unicode SMS means combining localization knowledge with flexible pattern matching.

For example, for Russian OTPs you might look for “код”, “пароль”, or “код подтверждения” keywords, while for Arabic you may look for “رمز”, “كود”, or “رمز التحقق”.

Practical Code Examples for Unicode SMS Parsing

Here are two brief code snippets demonstrating how to fetch SMS messages from SMSVerifier API and extract OTP codes using Unicode-aware regex.

python
import requests
import regex as re

API_KEY = "YOUR_API_KEY"
ORDER_ID = "ORDER_ID"

url = "https://smsverifier.com/stubs/handler_api.php"
params = {"api_key": API_KEY, "action": "getStatus", "id": ORDER_ID}
response = requests.get(url, params=params)
data = response.json()

if data["status"] == "STATUS_OK":
    sms_text = data["sms"]
    pattern = re.compile(r"\b(\p{Nd}{4,8})\b")
    matches = pattern.findall(sms_text)
    otp_code = matches[0] if matches else None
    print("Extracted OTP:", otp_code)
else:
    print("SMS not received yet or error.")
javascript
const fetch = require('node-fetch');

const API_KEY = "YOUR_API_KEY";
const ORDER_ID = "ORDER_ID";

async function getOtp() {
  const url = `https://smsverifier.com/stubs/handler_api.php?api_key=${API_KEY}&action=getStatus&id=${ORDER_ID}`;
  const res = await fetch(url);
  const data = await res.json();

  if (data.status === "STATUS_OK") {
    const smsText = data.sms;
    // Unicode digit regex using XRegExp library recommended
    const XRegExp = require('xregexp');
    const pattern = XRegExp('\\b\\p{Nd}{4,8}\\b', 'g');
    const matches = XRegExp.match(smsText, pattern);
    const otpCode = matches && matches.length > 0 ? matches[0] : null;
    console.log("Extracted OTP:", otpCode);
  } else {
    console.log("SMS not received yet or error.");
  }
}

getOtp();
Important context.

Node.js regex natively does not support Unicode properties; consider using libraries like xregexp for Unicode regex.

Testing and Debugging Your Automation

Before deploying your SMS code extraction automation in production, rigorous testing is crucial:

  • Use SMSVerifier's test phone numbers and API playground to simulate receiving Unicode SMS from target services.
  • Verify your regex patterns against sample messages in various languages to ensure no false positives or missed OTPs.
  • Log raw SMS messages during development to understand message structure and encoding.
  • Step 1 — Sign up Create an account and add funds via PayPal, card or crypto.
  • Step 2 — Pick service & country Choose the target service (e.g. WhatsApp) and the delivery country.
  • Step 3 — Receive code Enter the phone number on the target site; the OTP appears in your dashboard.
  • Step 4 — Extract code Use your Unicode-aware parsing logic to extract OTP automatically.
  • Pro tip.

    Implement fallback mechanisms if the first regex pattern fails, such as scanning for different OTP lengths or adjusting to new message templates.

    Frequently asked questions

    Can SMSVerifier API handle SMS messages in any language or script?
    Yes, SMSVerifier supports Unicode and can receive SMS messages in virtually any language or script, enabling global SMS verification.
    How do I parse OTP codes from SMS messages containing Unicode or non-Latin characters?
    You should use regex patterns adapted for Unicode digit ranges and normalize the text encoding to accurately extract codes from messages in different scripts.
    Does SMSVerifier API provide raw SMS message text for custom parsing?
    Yes, the API returns the full SMS text as received, allowing you to implement customized extraction logic tailored to your use case.
    Are there examples of code for Unicode OTP extraction using SMSVerifier API?
    Yes, SMSVerifier documentation and community forums provide examples in multiple languages including Python and Node.js to handle Unicode SMS parsing.
    What should I do if my OTP format differs per country or service?
    Maintain a configurable set of patterns per country or service and apply localization-aware parsing to successfully extract OTPs from diverse message formats.
    Can I test SMS code extraction with Unicode messages before deployment?
    Absolutely, SMSVerifier offers API playgrounds and test numbers to simulate receiving Unicode SMS messages for development and debugging.
    How does SMSVerifier handle delivery and refunds if SMS is not received?
    If no SMS arrives within the specified time frame, SMSVerifier automatically refunds your balance, ensuring no loss on failed attempts.

    Ready to automate OTP extraction from Unicode SMS?

    Register in 30 seconds — no card required, pay-as-you-go from $0.20 per SMS.

    Read the API docs
    Tags: smsverifier api sms-otp unicode automation code-extraction
    Browse Services A-Z
    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z #
    View all services →
    From Our Blog
    Browse all articles →