1. Detecting nya
The User-Agent is nya/2.8.5/Android/722837263881; it always starts with lowercase nya/.
| Check | Works? |
|---|---|
"NYA" in user_agent | No — case mismatch |
user_agent.lower().startswith("nya/") | Yes — recommended |
2. Python example
import base64
def b64(text: str) -> str:
return "base64:" + base64.b64encode(text.encode("utf-8")).decode()
def subscription_headers(user_agent, project_name, subscription_info, subscription_userinfo, routing):
ua = (user_agent or "").lower()
if ua.startswith("nya/"):
return {
"Content-Type": "text/plain; charset=utf-8",
"profile-update-interval": "3",
"profile-title": b64(f"{project_name}\n{subscription_info}"), # line 2 = announcement
"announce-url": f"https://t.me/{USERNAME_BOT}",
"support-url": SUPPORT_CHAT_URL,
"renew-url": f"https://t.me/{USERNAME_BOT}?start=renew",
"subscription-userinfo": subscription_userinfo,
"routing": routing, # happ://routing/onadd/<base64>
}3. Headers and details
| Header | Format | How nya uses it |
|---|---|---|
profile-title | text or base64:… | First line = title; further lines become the announcement when announce is absent |
subscription-userinfo | upload=0; download=123; total=456; expire=1798761600 | Integers; expire in Unix seconds; total=0 unlimited, expire=0 no expiry |
profile-update-interval | integer hours | Auto-update, default 12 |
announce | text or base64:… | Announcement above servers |
announce-url | https:// or tg:// | Makes the announcement a link; without text nya shows “Service news and announcements” |
support-url, renew-url, profile-web-page-url | URL | Support, Renew, website buttons |
routing | happ://routing/onadd/<base64> | Prefix doesn't matter; standard or URL-safe Base64 |
hide-settings | 0/1 | Server settings hidden by default; 0 shows them |
Non-ASCII text and emoji only in Base64: headers travel as Latin-1.
4. Status codes
404 — “Subscription not found”; 502 — “Subscription server is not responding”; other errors — “temporarily unavailable (code N)”, cached servers keep working.
5. Check
curl -sS -D - -o body.txt \
-A "nya/2.8.5/Android/722837263881" \
-H "x-hwid: 0123456789abcdef0123456789abcdef" \
-H "x-device-os: Android" -H "x-ver-os: 14" -H "x-device-model: Pixel 8" \
https://sub.example.com/sub/abc123