RU

Premium API

How the app checks premium and counts devices.

Overview

The provider list in the config file holds only Provider IDs and SHA-256 hashes of domains. Before applying premium parameters, the app asks the premium server whether premium is active and whether this device fits the paid limit. The domain is never sent in clear text.

Request

HTTP
GET https://nyaclient.com/api/p?h=<domain sha256>&d=<device number>
ParameterTypeRequiredDescription
hstringyesSHA-256 of the lowercase subscription domain, 64 hex chars
dstringnoAnonymous device number, 32 hex chars: first 32 chars of SHA-256 of nya-stats: + HWID. The HWID cannot be recovered from it

Response

If the domain is not registered:

JSON
{"premium": false}

If it is registered, the response is encrypted with a key derived from the domain. Only someone who knows the domain can read it:

JSON
{
  "v": 1,
  "n": "<base64, 16 bytes>",
  "d": "<base64, encrypted data>",
  "t": "<base64, 16 bytes, authentication tag>"
}
Decrypted fieldTypeDescription
idstringProvider ID
premiumbooleanPremium applies to this device
deviceLimitExceededbooleanThe device limit is used up and this device is new
untilnumberPremium end, Unix time
atnumberResponse time

Encryption

  • Key: HMAC-SHA256 keyed with nya-provider-api/1 over the subscription domain.
  • Stream: 32-byte HMAC-SHA256(key, nonce ‖ block number) blocks XORed with the data.
  • Integrity: first 16 bytes of HMAC-SHA256(key, tag ‖ nonce ‖ data). A response with a wrong tag is discarded.

Device limits

  1. The device is already counted. It keeps premium even when the limit is used up.
  2. New device, limit not reached. The device is counted and gets premium.
  3. New device, limit reached. The response is premium: false, deviceLimitExceeded: true. Premium features are off, the VPN works as usual.

A device is active if it checked in during the last 30 days.

Caching

  • The app checks premium on launch, when a subscription is added and together with the config file, about once an hour.
  • The answer is stored on the device for three days. If the server is unreachable, the last answer applies.
  • No more than 60 requests per IP per 10 minutes, otherwise 429.