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.
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.
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:
curl "https://smsverifier.com/stubs/handler_api.php?api_key=YOUR_API_KEY&action=getStatus&id=ORDER_ID"
Response snippet:
{
"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”.
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:
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
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.
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.")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();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.
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?
How do I parse OTP codes from SMS messages containing Unicode or non-Latin characters?
Does SMSVerifier API provide raw SMS message text for custom parsing?
Are there examples of code for Unicode OTP extraction using SMSVerifier API?
What should I do if my OTP format differs per country or service?
Can I test SMS code extraction with Unicode messages before deployment?
How does SMSVerifier handle delivery and refunds if SMS is not received?
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